Ok, the code below manages to create the cookie and its
in my cookie folder.....but the call to
$query->cookie("MY_NAME");
returns NULL( so does $ENV(COOKIE),$ENV(HTTP_COOKIE)...whatever)
Clive made the following comment....
Only cookies sent from the browser are stored in the $ENV{'HTTP_COOKIE'} / $q->cookie() object, so if you've just set the cookie, it's not available in that object until the browser next calls the script.
I dont understand this fully ??, maybe someone might spell it out for me....can i not just create a cookie and then request its contents in the next line of the very same script?
Or maybe the $ENV(COOKIE) variable is not available on tripod( would they be that mean)...ive set up an account with prohosting but im still having diffiulty getting it to run a script(something to do with chmod i think)
anyway the script is named:
and the code is as follows
-------------------------------------------------------
Code
-------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;
use CGI;
my $query = new CGI;
my $cookie_out = $query->cookie(
-name=>"MY_NAME",
-expires=>'+24h',
-domain=>'cgi.tripod.com',
-secure=>0
);
print $query->header(-cookie=>$cookie_out);
print $query->start_html("Cookie Test");
# DEBUG TO SCREEN
print $query->p;
print $query->header(-cookie=>$cookie_out);
print $query->p;
my $cookie_in = $query->cookie("MY_NAME");
if($cookie_in)
{
print $cookie_in;
}
else
{
print "Can't find the cookie";
}
print $query->p;
print $query->end_html;
BROWSER DISPLAYS
Set-cookie: domain=cgi.tripod.com; expires=Monday, 27-Aug-2001 22:50:49 GMT Content-type: text/html
Can't find the cookie
COOKIE CONTAINS
0
782699264
29437766
42193056
29437564
*
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.