in reply to Understanding the Use of Session Variables

To pass session variables between different pages you normally use cookies. CGI::Session::Tutorial should answer most of your questions.

Oh, and use CGI::Session and CGI instead of hand-rolling your own CGI parser (looking at that nasty split line...)

  • Comment on Re: Understanding the Use of Session Variables

Replies are listed 'Best First'.
Re^2: Understanding the Use of Session Variables
by spickles (Scribe) on Mar 05, 2009 at 16:22 UTC
    Thanks for the reply. I am already using CGI (from my code above I didn't show you that $q-> new CGI();) and I am looking to use CGI::Session b/c I agree that splitting the QUERY_STRING is not the best method. But then again, we all crawled before we ran, right? I'm not a programmer by any means. It is simply by the virtue of the helpful folks here at PerlMonks and countless hours of reading/writing/testing that I am able to perform the minimal Perl/CGI writing that I do. Once I set a cookie, how to I access it from the second page? I'm assuming that if I use the default method for generating a cookie that it's name will be the session ID. So I still have to know what that is to reference the cookie from page two, right?

    my $session = new CGI::Session(); print $session->header();
      Did you even read the tutorial I linked to? In the end you have to understand what you're doing, and the best way is to read introduction level tutorial like the one I gave you, and then start experimenting.
      Once I set a cookie, how to I access it from the second page?

      By using CGI:Session. It looks in the header, finds the session ID in the cookie, and then loads the session object from local storage.

      A reply falls below the community's threshold of quality. You may see it by logging in.