Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: CGI::Session and cookie expiration

by amt (Monk)
on Oct 18, 2004 at 17:33 UTC ( [id://400240]=note: print w/replies, xml ) Need Help??


in reply to CGI::Session and cookie expiration

Seumas, I wrote a script a while ago using LDAP for logins, and ran into a similar problem. What I ended up doing was to put a "expired" or "~logged-in" variable if you want to follow CGI::Session::Cookbook. The code is below, but what you need to do with this implementation is fetch the session, and check for the existance of that session variable, because when the expiration is triggered it disappears. This helps with inactivity expirations, because every time you go to the session on the server, you can just touch that session variable.

if( $authority = verify_password(\@autharray)){ # ldap authentication succeeded at this point # set session variables and other expiry information my $session = new CGI::Session( "driver:MySQL", undef, {Handle + => $dbh}) ; my $sid = $session->id; syslog( 'notice', "sid: %s", $sid); $session->param("~logged-in",1); $session->param("username",$autharray[0]); $session->param("org-name",$autharray[2]); $session->expires("~logged-in", "+15m"); syslog( 'notice',"after session writing") if $debug; # write cookie information to user browser my $cookie = $cgi->cookie(CGISESSID =>$session->id); print $cgi->header(-cookie=>$cookie); # ... # other proprietary stuff }


I hope this helps.

amt.

perlcheat

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://400240]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-26 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found