Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   CGI::Cookie problem (http://www.velocityreviews.com/forums/t902661-cgi-cookie-problem.html)

dalyea@gmail.com 04-12-2007 06:46 PM

CGI::Cookie problem
 
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



All times are GMT. The time now is 11:37 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.