creating a new session when a session is expired

A

alexjaquet

Hi,

After reading the documentation about CGI::Session I didn't find any
way to create a session when it's expired.

Now I'm using the following code to create a new session

local our $session_id=$query->param('session');
if ($session_id eq '' or $session_id eq '$SESSIONID') {
$session = new CGI::Session("driver:File", undef,
{Directory=>"$session_dir"});
$session->expire(3600);
$session_id = $session->id();
}

how can I extend this piece of code when a session exist but expired ?

Thanks for your advice.

Alexandre JAQUET
 
X

xhoster

Hi,

After reading the documentation about CGI::Session I didn't find any
way to create a session when it's expired.

docs for new():
If called with a single argument, it will be treated
either as $query object, or $sid, depending on its
type. If argument is a string , "new()" will treat it
as session id and will attempt to retrieve the session
from data store. If it fails, will create a new ses-
sion id, which will be accessible through id() method.

So you call new with the claimed session id if there is one. If it had
expired, or doesn't exist in the first place, a new session will be created
automatically. Otherwise the old one will be retrieved.
Now I'm using the following code to create a new session

local our $session_id=$query->param('session');
if ($session_id eq '' or $session_id eq '$SESSIONID') {

Where does $SESSIONID get set? What does it get set to?

Xho
 
X

xhoster

It doesn't get set to ANYTHING, it's a string that looks confusingly
like a variable.

Ah, yes. I missed that. I not sure if that makes things clearer or
even less clear.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top