in reply to Re: CGI::Session - non-stop session creation problem
in thread CGI::Session - non-stop session creation problem

my $session = new CGI::Session(undef, $empty, {Directory=>"c:/apac +he/sessions"}); $session->expire('+18h'); $session->param("userID", $userID); my $cookie = $foo->cookie(-name => 'main', -value => $session->id, -expires => '+30d', -path => '/'); print $foo->header(-cookie => $cookie);

So basically, someone logs in & a cookie is set.

Then, logged in or not, people visit pages that have the following code:
my $sid = $foo->cookie('main') || undef; my $session = new CGI::Session(undef, $sid, {Directory=>'c:/apache/ses +sions'});
The problem is that, regardless of whether or not the cookie exists, a new session is created.
The ONLY time I want a session created is in the login script, when the cookie & session should be created.
AFTER that, I would simply like to grab the session data *IF* one exists.

Right now, every time a page is loaded, if a session doesn't exists one is created... and then because a cookie isn't stored every time a page is visisted, the next page that's loaded creates a new session because a cookie containing the session data from the previous page wasn't stored. I don't want it to create a new sessions/cookie on every page, only on the login script.

Any thoughts/suggestions?

Stenyj