CGI::Cookie problem

D

dalyea

I am trying to get cookies working on a new site, but no luck.
The sites are on the same web server and so have a very similar
Apache setup. Then only difference worth noting is that the
working code is a dot.com and my new site where the code isn't
working is a dot.org. Should that make a difference?

The thing that I believe is broken is fetching the cookie(s).

The part that sets the cookie is this:

my $cookie = setZoneCookie($login, $pswd, $login_type);
my $url=qq(/cgi-bin/new.cgi);
print $cgi->header( -cookie => $cookie );
# print $cgi->start_html(-head => meta( { -http_equiv=>"refresh", -
content=>"0;URL=$url" } ));
print qq(
<html>
<head>
<meta http-equiv="refresh" content="0;URL=$url">
</head>
</html>
);

and the cookie is set by:

our $COOKIEDOMAIN=$cgi->virtual_host();
sub setZoneCookie {
my ($login, $pswd, $area) = @_;
my ($cookie, $c_name, $dough);

$dough = "$login,$pswd";
$cookie = new CGI::Cookie(
-NAME => $cookie_names{$area},
-VALUE => $dough,
-EXPIRES => '+24h',
-DOMAIN => $COOKIEDOMAIN
);
return $cookie;
}

I can see in debugging that the cookie looks right, just like any
other cookie:

xyz_cookie_staff=david%2Ciiikkk; domain=www.xyz.org; path=/;
expires=Fri, 13-
Apr-2007 18:28:57 GMT

The problem I think is fetching the cookie(s):

sub getLoginCookie {
my $area = shift;
my ($dough, @login);

%cookies = fetch CGI::Cookie;

if ($cookies{"xyz_cookie_staff"} ) {
$dough = $cookies{$cookie_names{$area}}->value;
}

# Dump
foreach my $x (sort keys %cookies) {
&daprint("dump - $x - $cookies{$x}");
}

The dump produces:

dump - CP - CP=%2A; path=/

I've tried clearing cookies IE-wide, and I've run and re-run the same
code on other sites with no problem. Any ideas?

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top