I suspect it may be that you are not actually writing the session file, probably due to File::Spec::tmpdir returning a dir you can't write. CGI::Session fails silently in this case. Try adding END{ warn $session->error } to pick up any errors.

You are making harder work of it than required. Try something like this with a hard coded tmpdir file. CHECK to see that your session files are getting written there.

my $q = CGI->new; # this will return a session object. # if the CGISESSID is avialable via cookie or param # that is what's used, otherwise it is a new session my $session = new CGI::Session("driver:File", $q, {Directory=>'/tmp'}) +; # this prints a header with the CGISSESSID cookie: print $session->header() # now if you want to stick it in a form as well, get the SESSID my $sessid = $session->id; # and stick it in the form..... print <<HTML; <form> <input type="hidden" name="CGISESSID" value="$sessid"> </form> HTML

cheers

tachyon


In reply to Re: Problem with CGI::Session module -- Getting a new session every time by tachyon
in thread Problem with CGI::Session module -- Getting a new session every time by larryp

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.