...

View Full Version : problem with session (CGI::Session)



dark0s
03-20-2010, 12:31 PM
I have a problem with CGI::Session.
I initialize a session at login with login.cgi script, but
how can I retreive my session id or data when I stand in other html
pages or scripts.
I saw that CGI.pm has not a method to retreive session data.
How can solve this problem?

Thanks in advance,
Savio

FishMonger
03-20-2010, 01:26 PM
You need to create a CGI::Session object and use that object to retrieve the session data.

bazz
03-20-2010, 02:50 PM
http://search.cpan.org/~markstos/CGI-Session-4.20/lib/CGI/Session.pm
http://search.cpan.org/~markstos/CGI-Session-4.20/lib/CGI/Session/Tutorial.pm

I hope you come back with questions after reading those.

Make sure, as well, that you put the code for the session in the correct files, especially if using several files to compile a web page. That was the thing I found least reading material about and where the biggest of my issues were, which, of course, were fixed with the help of FishMonger.

You mentioned that you wanted to use the session in html pages. I doubt you can if you store the session on the server.

bazz

dark0s
03-20-2010, 03:06 PM
You need to create a CGI::Session object and use that object to retrieve the session data.
If I create a new CGI::Session object, then I create new session and new coockies, instead I want to use session already in use.


http://search.cpan.org/~markstos/CGI...CGI/Session.pm
http://search.cpan.org/~markstos/CGI...on/Tutorial.pm

I hope you come back with questions after reading those.
I read above documentation.


You mentioned that you wanted to use the session in html pages. I doubt you can if you store the session on the server.
In fact, but how can I retreive that informations by methods without creating new session?

FishMonger
03-20-2010, 03:08 PM
When you create the object, use load instead of new.

http://search.cpan.org/~markstos/CGI-Session-4.42/lib/CGI/Session.pm#load%28%29

bazz
03-20-2010, 03:59 PM
If I create a new CGI::Session object, then I create new session and new coockies, instead I want to use session already in use.

I read above documentation.

From cpan tutorial:


Whenever you're ready to create a new session in your application, do the following:

$session = new CGI::Session() or die CGI::Session->errstr;

Above line will first try to re-initialize an existing session by consulting cookies and necessary QUERY_STRING parameters. If it fails will create a brand new session with a unique ID, which is normally called session ID, SID for short, and can be accessed through id() - object method.


hth

bazz

dark0s
03-20-2010, 04:20 PM
My code session in login.cgi is the following:

my $session = new CGI::Session(undef, undef, {Directory => '/tmp'});
$session->param(-name => '_CLIENT', -value => $columns[0]);
$session->param(-name => '_EMAIL', -value => $columns[1]);
$session->expire('+1h');

and generate a specific id for session.
My problem is how can retreive that specific id in search.cgi or index.html?

bazz
03-20-2010, 04:30 PM
I use this in my perl files.

my $session_id = $session->id();


hth



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum