Here is a small perl cookie test script. Put this cookietest.cgi in the same folder as manage_users.cgi. Access with browser and click the create button several times to see cookies created. Then repeat press the refresh button to see them expire after 20 seconds and disappear. This should show whether the problem is with your script, browser or server.

#!/usr/bin/perl # cookietest.cgi use strict; use CGI ':standard'; use CGI::Cookie; use Data::Dumper; my $time = scalar localtime; my $cookie; if ( param('action') ){ $cookie = new CGI::Cookie( -name => (sprintf "TESTCOOKIE_%05d",rand(10000)), -value => $time, -expires => '+20s' ); CGI::delete_all(); print redirect( -cookie => $cookie ); } my $JS =<<EOJ; function display_ct() { var x = new Date() document.getElementById('ct').innerHTML = x; } EOJ print header( -cookie => $cookie ), start_html( -title => "cookietest.cgi", -script=>$JS, -onLoad=>"display_ct();" ), h2("Cookie Test"), h3("Server time is : $time"), h3("Client time is : <span id='ct' ></span>"); print start_form( -method => "POST" ); print submit("action","create cookie"); print submit("refresh","refresh"); print end_form; my %cookie = CGI::Cookie->fetch; my $count = keys %cookie; print h3("There are $count cookies"); print pre( Dumper \%cookie ),end_html;
poj

In reply to Re^7: Cookie->fetch problem by poj
in thread 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.