All, I am having problem setting cookie manually. Hoever, I have no problem setting it via CGI qw(:standard). But for my educational purppose, I would like to know why this piece of code is not setting my cookie.
#!/usr/bin/perl
# example_5-1.cgi
use strict;
print qq(Content-type: text/html\n");
print qq(Set-Cookies: username=Fred Flinstone; );
print qq(expires=Mon, 01-May-2003 00:00:00 GMT; );
print qq(path=/);
print qq(\n\n);
print qq(A cookie has been set in your browser...<P>);
print qq(<A HREF="example_5-2.cgi">);
print qq(Click to view the cookie</A>);
here's the code that checks if the cookie is set:
#!/usr/bin/perl
#example_5-2.cgi
use strict;
my ($key,$value) = split(/=/,$ENV{HTTP_COOKIE});
print qq(Content-type: text/html\n\n);
print qq(The cookie <B>$key</B> contained <B>$value</B>);
When I call the code via my browser: http://localhost/cgi-bin/play/example_5-1.cgi this sets the cookie and http://localhost/cgi-bin/play/example_5-2.cgi this displays it, but the cookie is not displaying. I even check Konqueror for the cookie, but there's nothing there from localhost. Does any one see anything wrong with this? Thanks.