intranetman has asked for the wisdom of the Perl Monks concerning the following question:
sub setCookie($) { my($session) = @_; my $query = new CGI; $sid = $session->id(); $cookie = $query->cookie(-name => "CGISESSID", -value => $sid, -expires => '+1h', -path => '/tmp/Sessions'); print $query->header(-cookie=>$cookie); }
And the code to retrieve the cookie:
sub retrieveSession($) { my ($query, $session) = @_; $sid = $query->cookie(CGISESSID=>$session->id) || undef; $sid = substr($sid, 10, -8); $session = new CGI::Session(undef, $sid, {Directory=>'/tmp/Session +s'}); $sid = $session->id(); $session = getUser($session, $sid); return $session; }
Where getUser returns the login name and password of the user logged in from a database. The getUser function isn't the problem its the $sid = $query->cookie(CGISESSID=>$session->id) || undef;.
If I don't pass the session then it won't find the cookie although its right there in /tmp/Sessions. ARGH!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Cookie Problems
by chromatic (Archbishop) on Sep 29, 2004 at 20:37 UTC | |
by intranetman (Acolyte) on Sep 29, 2004 at 21:09 UTC | |
by geekgrrl (Pilgrim) on Sep 29, 2004 at 22:09 UTC | |
by intranetman (Acolyte) on Sep 30, 2004 at 16:40 UTC | |
by chromatic (Archbishop) on Sep 30, 2004 at 17:58 UTC | |
| |
by geekgrrl (Pilgrim) on Sep 30, 2004 at 19:22 UTC | |
by intranetman (Acolyte) on Oct 05, 2004 at 17:17 UTC |