in reply to cgi::session issue with session data retrival

Firstly, add use strict; and use warnings; to your scripts. When you've done this, Perl will start helping you. You'll need to fix a few things, e.g. changing $cgi = new CGI; to my $cgi = new CGI; - I can see a couple more like that.

Next, take a look at CGI::Session::Tutorial.

If you're still experiencing difficulties, post your updated code as well as any relevant output.

-- Ken

Replies are listed 'Best First'.
Re^2: cgi::session issue with session data retrival
by saifuddin786 (Initiate) on Oct 26, 2010 at 18:11 UTC
    Have updated the code as per the suggestion (as updated in the question). Now i am seeing the below error in the second file while retrieving the session data. Can't locate auto/CGI/Session/File/expire.al in @INC (@INC contains: D:/TBD/xampp/perl/lib D:/TBD/xampp/perl/site/lib .) at D:/TBD/xampp/perl/lib/CGI/Session.pm line 258

      Looking through the documentation for CGI::Session, I see that there are a number of formats for new(); none of which equate to what you have in session2.pl:

      my $session = new CGI::Session(undef, $sid, {Directory=>'d:/TBD'});

      Compare that with the equivalent line in session1.pl.

      Also, I'd recommend using the Class->new form instead of the new Class form. Take a look at Indirect Object Syntax in perlobj for a discussion of this. It's a good habit to get into and may save you some grief down the track.

      -- Ken

        it worked after i used CGI::Session->load($sid). Thanks a lot. It worked for a string, now i need to stored a object :). lets see how it works.