Subject: | Session not restored if previous attempt to load session failed |
I had a problem with loading the correct session which I fixed with the patch below.
I use Session-State-Cookie.pm for all actions except for one (coming from Flash/Ajax where I can't set request
headers). For that one action I put sessionid in query parameters.
Session-State-URI.pm is grabbing the sessionid during prepare_action, but something has already tried
loading/reading a session before that. Therefore _tried_loading_session_id is already true so the sessionid via URI is
never used.
I haven't written any failing tests, not sure how to do that for this issue. Some guidance for writing a failing test
would be appreciated.
The patch which fixed the problem for me:
--- Session-State-URI.pm 2010-05-19 12:08:50.000000000 +1000
+++ /Library/Perl/5.8.8/Catalyst/Plugin/Session/State/URI.pm 2010-05-19 12:10:52.000000000 +1000
@@ -320,6 +320,7 @@
if ( my $sid = $c->request->param($param) ) {
$c->_sessionid_from_uri($sid);
+ $c->_tried_loading_session_id(0);
$c->log->debug(qq/Found sessionid "$sid" in query parameters/)
if $c->debug;
}
@@ -331,6 +332,7 @@
$c->log->debug(qq/Found sessionid "$sid" in uri path/)
if $c->debug;
$c->_sessionid_from_uri($sid);
+ $c->_tried_loading_session_id(0);
}
}