Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl Sessions

perl sessions cookies

         

eltreno

10:38 am on Apr 26, 2005 (gmt 0)

10+ Year Member



Hi I have done some perl a few years back but rescently doing PHP

Now back on a perl project and haveing problems with sessions

I basically want to do simpliar things you can do in php like if (sees_var = 'whatever') do this

I've been on search:cpan etc and can print from a session when storing from a cgi param, but on next visit to same page a new session is constantley being made.

Some of my code from cpan


use CGI::Session;

$session = new CGI::Session("driver:File", undef, {Directory=>"/tmp"});

$sid = $session->id();

$cookie = $cgi->cookie(CGISESSID => $sidvariable);
print $cgi->header( -cookie=>$cookie );

I have brought things back to it's simplist state and now even get an error saying

Can't call method "cookie" on an undefined value

I was also trying
$sid = $cgi->cookie('CGISESSID') ¦¦ $cgi->param('CGISESSID') ¦¦ undef;
$session = new CGI::Session(undef, $sid, {Directory=>'/tmp'});

to try and retrieve last sess value but no go, new sessions always being created

Any help or a simply script would be greatly appreciated

Thanks
Trent

moltar

11:04 pm on Apr 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am not sure how your script works, but I think it would make sense to check if you have a session running already before creating a new one.

unless ( session exists ) {
create new session
}