I attempt to retrieve the session as follows:.. $session->save_param($cgi); setCookie($cgi, $session); .. sub setCookie($) { my($cgi, $session) = @_; $cookie = $cgi->cookie(CGISESSID=> $session->id); print $cgi->header( -cookie=>$cookie); }
Where CGISESSID should be cache (right? wrong?). Now, I could return the cookie, but that doesn't make sense as it is supposed to be cached or written to the clients disk. So when I login I have a sessionid of say a983c8302e7a678a2e53c65e8bd3316, but when I try to retieve that value with a small script I get a new value 9ccaa7a41f78970bb804b4afa9e8cb4c.sub retriveSession() { my $cgi = new CGI; $sid = $cgi->cookie("CGISESSID") || $cgi->param('CGISESSID') || undef +; $session = new CGI::Session(undef, $sid, {Directory=>'/tmp/Sessions +/'}); if ((undef($sid)) || (undef($sessions))) { print "<li> You are currently not logged. You will now be return +ed to the login page! </li> \n"; print qq{<meta HTTP-EQUIV=REFRESH content="1; url=http://www.myu +rl.com/login.html">}; exit(0); } }
I've read through the CGI::Session, CGI Cookie pages, and perldocs, but nothing. They keep saying that you can retrieve the session parameters using something similar $session->load_param($cgi, ["fruits"]);, but that presupposes that the session variables is already passed.
Do I have to pass the cookie and session variables as headers to each page? This doesn't seem right as it should be kept on disk or in memory until expiration. My implementation is pretty similar to that in the Tutorial, however, I wrote my own drivers for MySQL. I thought about using CGI::Session:Serialize the process, but this adds another security issue.
I think I've confused myself. Any Perl Wisdom would be helpful, thanks once again!
In reply to CGI::Session Handling by intranetman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |