I can hear the screams now. Yes, another cookie question. Before posting I did read a previous node which came close, but I'm still not getting it. So, before I go back to the dreaded javascript....

Here I check to see if the user has logged in. If they haven't, or it's been > 15 min, they are sent to the login script. Otherwise, a new "session" is started. I'm able to set the cookie, but I'm not able to read it. In the aforementioned node, is chromatic saying that I can't try to read a cookie and then set one at the same time? If so, how am I to get around it? Thanks in advance.
#!/usr/bin/perl print "Content-type: text/html\n\n"; use strict; use CGI; my $query = new CGI; my $username = int(rand 1000000); my $cookie = $query->cookie('xmsessionID'); #check for cookie if (!$cookie) { print "No cookie<br>"; #for testing purposes goto &login } else { print "Cookie found: $cookie<br>"; #for testing purposes } #-------- write new cookie ----------- my $newcookie = $query->cookie(-name=>'xmsessionID', -value=> $username, -expires=>'+15m'); print $query->header(-cookie=>$newcookie);

—Brad
"A little yeast leavens the whole dough."

In reply to Not able to set and retrieve cookie by bradcathey

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.