开发者

Why does my CGI::Session keep emptying itself randomly?

The session loads fine for the most part but it is randomly clearing all of the data some times and I don't know why:

Create my new session:

$session = CGI::Session->new( "driver:file",undef,{Directory => '/tmp'} );

$session->param('logged_in', 1);
$session->expire('logged_in', '+10m');

$session->expire('+1h');

Now when I go to another page and load the session I do:

$session = CGI::Session->load ( "driver:file", $sid, {Directory => '/tmp'} );

return 0 if $session->is_expired;

return 0 if 开发者_如何学JAVA!$session->param('logged_in');

return $session;

The problem I have is that sometimes, before the 10 minute mark is up the 'logged_in' param is empty when it should not be. Why could this be happening?


First, you do not seem to be using strict: You should. Second, don't use indirect object notation. I.e., use CGI::Session->new.

To find out what is going on, use the sequential id generator for debugging and make sure you are looking at the session you think you are looking at. Make sure you create the session on log on, but from that point on, you load it.

Check how you are keeping track of the session id: Are you using cookies, query string parameters or from parameters? Make sure the correct session id is available at all times.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜