Sorry for my completely bogus first reply *blush*
While it sounds good, it doesn't point you into the right direction.
CGI::Session encapsulates CGI to store parameters,
cookies and so on in a serialized data structure, so you don't need to use both of them. Choose one, use one.
Maybe you mended your confusion in the meantime - anyways:
2) I am confused as to how the username is picked up correctly, if I use'$session->delete();' in the script? (I don't see the 'cgisess_............' in the /tmp folder and I am sure it is getting deleted )
You grab the params before the call to $session->delete()
my $user = $session->param( "user" );
my $sid = $session->id();
my $cookie = $q->cookie( -name => $session->name(),
-value => $sid,
-expires => "+5" );
my $nextpage = 'test_cgi_session.pl';
$session->delete();
pass them to your template
$template->param( user => $user );
$template->param( sessionid => $sid );
and have them stuck into the value attribute of your inputs
<input type="input" name="user" value="<tmpl_var name=user>" />
</tr></td>
<tr><td>
<input type="input" name="sessionid" value="<tmpl_var name=sessionid>"
+ size="100" />
so it would be rather odd for $user not to show up in the text field.
3) Also, I am not sure why I don't need '$session->load_param(); ' call?
You need the $session->load_param() call if the only value passed into your cgi is the session ID, and you want to restore the params from the previously stored serialized data structure, i.e. if there wasn't any user name passed in, and you want the username to be passed to subsequent pages nonetheless - just the opposite of what you expected your script to do ;-)
I am really not sure if I am using CGI::Session correctly
Those who are sure, aren't ;-)
Look for the method 'dump' in CGI::Session and include dump($session) in your output to see what's in that session thing.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|