On Tue, 22 Mar 2005 22:20:14 +0200 (IST), Gabor Szabo <[EMAIL PROTECTED]> wrote:
>
> I still have some very strange behavior here:
>
> sub cgiapp_init {
>
> [some code skipped]
>
> $self->log->debug("Cookie received: " . $self->query->cookie($cookiename)
> );
> CGI::Session->name($cookiename);
> $self->session_config(
> CGI_SESSION_OPTIONS => [ "driver:File", $self->query, {Directory =>
> "/tmp"}],
> COOKIE_PARAMS => {
> -expires => '+24h',
> -path => '/',
> },
> SEND_COOKIE => 1,
> );
> $self->log->debug("sid: " . ($self->session->id() || ""));
>
> $self->header_props(
> -expires => '-1d',
> -charset => "utf-8",
> );
> $self->session_cookie();
>
> }
You have SEND_COOKIE set to 1, but then you are also calling
$self->session_cookie, which means that the cookie gets set twice.
However, you are also calling header_props in there, which is a bit
dangerous as it wipes out any previously set headers. You should
consider using header_add instead.
> In order to eliminate possible trouble with the database and CDBI I
> changed the code now to store the session data in files.
Not a bad idea, but you still need to make sure that the sessions are
being added to the file properly.
> but every time I access the application I string printed next to "sid"
> is different from the one next to "Cookie received".
It would have helped if you displayed a couple of samples. Is the sid
next to "Cookie received" the same as the sid that was assigned during
the last request? ie do you see something like this:
Cookie received:
sid: n1
Cookie received: n1
sid: n2
Cookie received: n2
sid: n3
Cookie received: n3
...
That would indicate the the cookies are being set correctly, but the
session is not being saved to the store.
> I am sure there is something obvious I am missing here
> or is this the normal behavior ?
My suggestion would be to go back to basics. You are part way there
by using the File based store, but I would also comment out the
session_config parameters and go with the defaults, comment out the
CGI::Session->name change you are doing, and let CAP::Session handle
the cookie. Also, get rid of the header_props call and replace it
with a header_add call.
That should work for you. The only thing that could go wrong with
that setup is if you don't have a /tmp or C:\TEMP directory, or it is
not writable.
If that still doesn't work, and you are confident that you are not
running in a persistent environment, then I don't know what is
wrong... If you still have trouble, maybe send more code (if you
don't want to send it all to the list, you can send it privately, but
I can't guarantee I'll have time to look through all of it right
away).
Cheers,
--
Cees Hek
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]