Dear Monks,
I am working on a cookie-managed community system but my cookies expire too inaccurately, in detail: too early.
I am using Apache 1.27x on a Win32 (NT 5.1) machine, ActiveState Perl 5.6 and the module CGI.
With the script shown below, the cookie is supposed to expire 10 minutes after being set. I have counted the time and found out that it actually expired after 8 minutes and ~50 seconds. When I do this test again with
-expires => "+30s", the cookie won't be set at all.
Do you have any Ideas how this problem can be solved?
#!C:\Perl\bin\perl.exe
use strict;
use CGI;
my $q = CGI->new();
my $service = $q->param('service') || '';
&printCookieContent() if ($service eq 'showcookie');
sub printCookieContent
{
my $cookie = $ENV{HTTP_COOKIE};
my ($name, $value) = split(m/=/, $cookie, 2);
print $q->header('text/html');
print "$name<br>$value";
exit;
}
my $cookie = $q->cookie( -name => "Testname",
-value => "Testvalue",
-domain => "abroxa.dyndns.org",
-expires => "+10m",
-path => "/cgi-bin"
);
print $q->header(-type => 'text/html', -cookie => $cookie);
print qq ~<a href="cookietest.cgi?service=showcookie">klick here to te
+st the cookie</a>~;
exit;
BioHazard
reading between the lines is my real pleasure
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.