My next questions is how do I retrieve those old values since technically it could be looking for any CGISESSID that has been loaded. In other words, is it imperative that I pass CGISESSID to/between each html/cgi document that the client visits? I am using the following (updated) code to store and retrieve cookies:
Even though I have a cookie stored on disk that I can see the getUser and retrieveSession functions are not working properly. I would think that I wouldn't need to append cgisess_ to the beginning of the session id like cgisess_a983c8302e7a678a2e53c65e8bd3316 because it should take care of this automatically? Any other ideas? Thanks once again for helping out!sub setCookie($) { my($session) = @_; my $q = new CGI; $sid = $session->id(); $cookie = $q->cookie(-name => "CGISESSID", -value => $sid, -expires => '+1h', -path => '/tmp/Sessions'); print $q->header(-cookie=>$cookie); } sub retrieveSession() { $query = new CGI; $sid = $query->cookie("CGISESSID") || undef; $session = new CGI::Session(undef, $sid, {Directory=>'/tmp/Session +s'}); $sid = $session->id(); $session = getUser($sid); print $session->param("log_name"); return $session; } sub getUser($) { my ($sid) = @_; $select = "SELECT username, password FROM Employees WHERE session_i +d = '$sid'"; $get_it = $db->prepare($select); $get_it->errstr, "\n"; $rv = $get_it->execute() or die "Couldn't execute query '$select' \ +n"; $get_it->bind_columns(undef, \$username, \$password); $get_it->fetchrow_arrayref(); $session->param(-name=>"log_name", -value=>$username); $session->pa +ram(-name=>"log_password", -value=>$password); return $session; }
In reply to Re^2: CGI::Session Handling
by intranetman
in thread CGI::Session Handling
by intranetman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |