PDA

View Full Version : Cookies Write and Read


quantumpixel
12-05-2002, 01:34 AM
first of all hello to everyone and i hope u can help me... :confused:

my problem is that i cant read or use the cookies value...
i can write them, and see them on my cookie directory, and sometimes i can check that there is a cookie using $ENV{HTTP_COOKIE}

however i never get the value of the cookie itself...

heres how i write it _____________________

print "Set-Cookie:user=$CookieS;expires=Tue, 31-Dec-2002 23:15:12 GMT; domain=www.moneysubmarine.com;path=/cgi-bin/MSv1/\n"

( i put this line before the print Content-type text/html )

this is how i read it _____________________

%CookieInfo = ();
$buffer = $ENV{'HTTP_COOKIE'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$CookieInfo{$name} = $value;
}

$USER_Log = $CookieInfo{'user'};

THANKS FOR UR HELP IN ADVANCE ! :thumbsup:

ACJavascript
12-18-2002, 08:08 PM
Well dont really see anything quite wrong with the way you are writting your cookies, but try this..

first, does the scalar $CookieS have a value?

Second, try this for the cookie code

print "Set-Cookie:user=$CookieS;expires=Tue, 31-Dec-2002 23:15:12 GMT;domain=www.moneysubmarine.com;path=/cgi-bin/MSv1/\n";