Hi there monks,
I've run into a strange problem: when I first login into my perl site,whos using CGI::Session to handle the sessions part, using FireFox or IE, the first login of the day returns me to the login screen again. The second time I try, I get in. Doing a little debugging on the login part I can see that the session is created on file in the directory I specified with all the right data in, the authentication part is correct but the browser doesn't see it.
Here is the code I used:
$s = new CGI::Session( "driver:file", undef, {Directory=>'/tmp/'} ) or
+ die CGI::Session->errstr;
# the user's data
$s->param('username',$user);
$s->param('userid',$userid);
$s->param('name',$name);
$s->param('surname',$surname);
$s->param('~logged-in',"true");
$ipaddr = $s->param('_SESSION_REMOTE_ADDR');
$hostname = qx#host $ipaddr |awk {'print \$5'}#;
# verify the user's access level
if($isadmin eq 1) {
$s->param('isadmin',"true");
} else {
$s->param('isadmin',"false");
$s->param('access',"11");
}
# register the last login
my $lastlogin = funcs::DB->dbgetuniq("SELECT access FR
+OM users_access WHERE userid=\"$userid\" ORDER BY access DESC","acces
+s");
$s->param('lastlogin',"$lastlogin");
$s->expire("~logged-in", "30m");
$s->expire('+6h');
# register the user access
funcs::DB->dbdo("INSERT INTO users_access VALUES('','$
+userid','$ipaddr','$hostname',NOW())");
print $s->header(-location=>'http://mysite/');
Any ideas?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.