Revered Chefs,
Please forgive a mere mod_perl kitchen-hand, undergoing early cookie
training... I have the following cookie code, but no cookies come
back when I refresh, and I don't see any $HTTP_COOKIE in %ENV.
$cookies ends up as a hash ref pointing to an empty hash.
I have the following in my httpd.conf:
PerlWarn On
PerlTaintCheck On
PerlFreshRestart On
PerlInitHandler Apache::Reload
PerlSetVar ReloadAll On
<Files *.pl>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader Off
Options +ExecCGI
</Files>
Help?? TIA
Jeff
# As you will note, this highly original recipe was lifted unchanged
# from Delia Smith's 'How to Boil Eggs for Breakfast'.
#------------------------------------------------
# This is the cookie dough that don't want to bake
use strict;
require "dumpvar.pl";
use Apache;
use Apache::Cookie;
# read in the cookie if this is an old session
my $r = Apache->request();
my $cookies = Apache::Cookie->fetch;
my $sent = '';
if (!$cookies->{foo} ) {
$sent = 'sending cookie';
my $cookie = Apache::Cookie->new(
$r,
-name => 'foo',
-value => 'bar',
-expires => '+1D',
-domain => undef,
-path => '/',
-secure => undef,
);
$cookie->bake;
} else {
$sent = 'received cookie';
}
$r->content_type("text/html");
$r->send_http_header;
print "$0 $sent", "<HR>";
main::dumpValue(\$cookies);
print "<HR>", $r->as_string, "<HR>";
map { print " $_ => '$ENV{$_}' <BR>\n"; } sort keys %ENV;
#------------------------------------------------