Let me just say before asking this question, that I've spent HOURS combing CPAN and other postings on how to do this and have NOT found any examples of how to accomplish this other than references to the CGI::SESSION tutorials, which give highlights of the functions, but no SPECIFIC examples of accessing from ANOTHER page without create a new session. Therefore, I'm looking for those who have specific examples, NOT a cut-and-paste of a link I've surely visited in my quest to get, what I'm sure is basic, but not very clearly outlined in documentation.

Issue: I've got a log in page that presents the user with a standard user id and log in. Once the user is successfully authenticated against a MYSQL database, a user session is created with the following code:
$session = new CGI::Session("driver:File", $cgi, {Directory=>"/temp"}) +; $cookie = $cgi->cookie(-name=>'CGISESSID',-value=>$session->id); $sid = $session->id(); print $cgi->header(-cookie=>$cookie ); # storing data in the session $session->param('sessionid', $session->id); $session->save_param(); # expire the session itself after 1 idle hour $session->expire('+1h');
This part works FINE. This issue I'm having is HOW to access the EXISTING session on another page. For example, I've include the following code at the top of another page that will check to see if a session has been initialized before proceeding with the displaying the page. However, it NEVER gets the session that has already been created, but, instead, creates nothing:
use DBI; use CGI; use CGI::Session; $session = CGI::Session->retrieve(); if ($session eq "") { print "Content-type: text/html\n\n"; print "<body>"; print "You must login first!"; exit; print "</body>"; print "</html>"; }
I know this is simple to some of you, but I just can't seem to get this basic functionality working :-( EXAMPLES PLEASE????

In reply to accessing session variables across different pages by s/^Perl/pain/i

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.