[prev] [thread] [next] [lurker] [Date index for 2003/09/10]
Author: richardc Date: 2003-09-10 11:56:29 +0100 (Wed, 10 Sep 2003) New Revision: 1407 Modified: trunk/siesta/lib/Siesta/Web.pm Log: lesson learned from timesink Modified: trunk/siesta/lib/Siesta/Web.pm =================================================================== --- trunk/siesta/lib/Siesta/Web.pm 2003-09-05 14:47:03 UTC (rev 1406) +++ trunk/siesta/lib/Siesta/Web.pm 2003-09-10 10:56:29 UTC (rev 1407) @@ -28,15 +28,27 @@ my $cgi = CGI->new; my $session_id = $cgi->cookie( Cookie ); - tie my %session, 'Apache::Session::SharedMem', $session_id, - +{ expires_in => 60 * 60 }; # 1 hour + my %session; + # try the session in the cookie, or a new one + for my $id ($session_id, undef) { + eval { + tie %session, 'Apache::Session::SharedMem', $id, + +{ expires_in => 24 * 60 * 60 }; # 24 hours + }; + last unless $@; + } - my @headers; - push @headers, [ 'Set-Cookie' => - $cgi->cookie(-name => Cookie, - -value => $session{_session_id}) ] - unless $session_id; + unless ( $session{_session_id} ) { + $r->log_reason( "couldn't get session" ); + return SERVER_ERROR; + } + my @headers = ( + [ 'Set-Cookie' => + $cgi->cookie(-name => Cookie, + -value => $session{_session_id}) ] + ); + my $params = { set_header => sub { push @headers, @_; return }, uri => $r->uri,
Generated at 13:57 on 01 Jul 2004 by mariachi 0.52