Greetings,
Im unable to reproduce your problem. I would suggest looking into using CGI::Cookie for cookie parsing especially if you are unsure of the source of those cookies. Also Mozilla(netscape) has a really handy cookie manager so you can see if your cookies are being set and how.
Here is how I tested it (and I got something back).
#!/usr/bin/perl -w use CGI; use CGI::Cookie; use strict; use Dumpvalue; my %cookies = fetch CGI::Cookie; my $q = new CGI; if(%cookies){ dump_ref(\%cookies); }else{ my $this_url = $ENV{'SCRIPT_NAME'}; print $q->header(); ################################################# #pasted code from posting ################################################# print qq* <script language=javascript type="text/javascript"> <!-- function SetCookie(username, value, expires, path, domain){ document.cookie = username + "=" + escape(value) + ((expires == null) ? "" : "; expires=" + expires.toGMTString() +) + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain); } var expiration = new Date(); expiration.setTime(expiration.getTime() + 60000); SetCookie('username', 'Peter', expiration); // --> </script> <br> <a href="$this_url">Check cookies</a> *; exit; } ################################################# #what do we have in there? ################################################# sub dump_ref { my $ref = shift; my $dumper = new Dumpvalue; print $q->header(); print "<pre>"; $dumper->dumpValues($ref); print "</pre>"; exit; }
simple I know but I hope that helps.
I was wondering about your line
var expiration = new Date(); expiration.setTime(expiration.getTime() + 60000);
was expiration suppose to be expires?
-injunjoel

In reply to Re: javascript.. perl.. cookie by injunjoel
in thread javascript.. perl.. cookie by wolverina

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.