[Cgi-session-user] Problem while using CGI::Session module
Brought to you by:
sherzodr
From: Srikanth M. <sri...@gm...> - 2009-10-09 21:52:42
|
Hi, I am currently developing a website which is hosted on startlogic.com. I was trying to implement sessions on my site and have tried to use the CGI:Session module as described on the CPAN site. I am able to generate a session header and a cookie for the session, but the problem I am facing is that I am unable to retrive the session information on the next page. Following is the sample code that I have tried : ******* code on page 1 ************************** #!/usr/bin/perl use CGI::Carp 'fatalsToBrowser'; use LWP::Simple; use CGI qw(:standard); use CGI::Session; import CGI; print "Content-type:text/html\n\n"; $session = new CGI::Session(); $CGISESSID = $session->id(); print $session->header(); $session->param('user',"XYZ"); print "hi!\n"; print $session->param('user'); print "<a href=session2.cgi>Try this on page 2</a>"; ******************** Code on Page 2 ******************* #!/usr/bin/perl use LWP::Simple; use DBI; use CGI qw(:standard); use CGI::Session; import CGI; print "Content-type:text/html\n\n"; $session = new CGI::Session(); $CGISESSID = $session->id(); print $session->header(); $user=$session->param('user'); print "<h2>User is $user</h2>"; ************************************** The print $session->param('user'); prints the result 'XYZ' on the first page, but is just *returning a blank on the second page*. I have tried many different combination of codes to make it work, but it still is giving the same problem. Iv tried to read many related forums, but am unable to find a solution. Kindly let me know if there is a solution to this. Any kind of help would be greatly appreciated. Thank you for your time. Regards, Srikanth |