Monday, May 23, 2011

perl session cgi

http://search.cpan.org/dist/CGI-Session/lib/CGI/Session/Tutorial.pm


$session = CGI::Session->load() or die CGI::Session->errstr;
if ( $session->is_expired ) {
    die "Your session expired. Please refresh your browser to re-start your session";
}
if ( $session->is_empty ) {
    $session = $session->new();
}


print $session->header();

#save into session
$session->param('username',$username);

#read from session
$variable = $session->param('username');

No comments:

Post a Comment