AM above was right though probably not helpful for you. There is no such method as retrieve in CGI::Session. The session and cookie handling are done by creating a new object. You can configure it many different ways but it should work out of the box with tmp files and an auto-named cookie following the examples directly.

# (mostly) From the tutorial link above- use strict; # Important! use warnings; # Ditto! my $session = CGI::Session->new() or die CGI::Session->errstr; Above line will first try to re-initialize an existing session by cons +ulting cookies and necessary QUERY_STRING parameters. If it fails wil +l create a brand new session with a unique ID, which is normally call +ed session ID, SID for short, and can be accessed through id() - obje +ct method. We didn't check for any session cookies above, did we? No, we didn't, +but CGI::Session did. It looked for a cookie called CGISESSID, and if + it found it tried to load existing session from server side storage +(file in our case). If cookie didn't exist it looked for a QUERY_STRI +NG parameter called CGISESSID. If all the attempts to recover session + ID failed, it created a new session.

I know you said you spent hours reading CPAN docs so you might have seen it already but that tutorial is pretty direct and you're not likely to get a better answer anywhere. Your username prompts the following jest-

s/(?<=Reading )[^.]+(?=.)/is fundamental/;

I know how frustrating some of this can be at first. I've done the same hours of reading or 500 permutations on a theme based on an assumption. But stick with it. It gets more fun all the time. :)

Oh, all right. Just thinking about the days I wasted early on because I was just missing some simple piece... Here, you go, a minimal working example. You should be able to play with configuration and code order pretty easily from this-

use strict; use warnings; use CGI::Session; use CGI qw( h1 p ); use CGI::Carp "fatalsToBrowser"; my $session = CGI::Session->new or die CGI::Session->errstr; print $session->header(); if ( $session->param("visits") ) { print h1("Welcome back!"); print p( sprintf("You've been here %d time%s.", $session->param("visits"), $session->param("visits") == 1 ? "" : "s", ) ); } else { print h1("Welcome first time visitor"); } $session->param( visits => $session->param("visits") + 1 );

In reply to Re: accessing session variables across different pages by Your Mother
in thread 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.