Hi: I am asking here as a last resort. I have this little subroutine that I am trying to recover cookie info to calling routine to determine whether use is logged in. The SID gets stored in the session table each time I log in. Over and over. This subroutine returns 0 on each attempt This warn("GetUserSessionCookie SID: $sid"); posts to error log: GetUserSessionCookie sessionname: '' at /home/jalamior/www/httpsdocs/cgi-bin/lib/perl/manageusers.pm line 673. I have seen fetch two different ways in literature CGI::Cookie->fetch. and fetch CGI::Cookie; ?????? Neither seems to work Since my $sessionname = 'CGISESSID'; is defined as global in the module, I am assuming that this code will recover only the cookie info associated with that name. Brain dead. Thanks

sub GetUserSessionCookie { warn("Entered GetUserSessionCookie"); use CGI qw/:standard/; # fetch existing cookies my %cookies = CGI::Cookie->fetch; warn(%cookies); my $sid; # warn("GetUserSessionCookie sessionname: '$cookies{$sessionname}'" +); if ($cookies{$sessionname}) { $sid = $cookies{$sessionname}->value; warn("GetUserSessionCookie SID: $sid"); } else{ $sid = 0; } return $sid; }

In reply to Cookie->fetch problem by tultalk

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.