View Full Version : COOKIES ? cant read them !

09-12-2002, 08:04 PM
ok me again... i cant read the cookies i have succefully set on the clients computer this is the code im using to load the cookies


if ($ENV{'HTTP_COOKIE'}) {

@cookie = split (/;/,
foreach $cookie (@cookies) {
($name, $vale) = split (/=/,
$crumbs{$name} = $value;



can anyone help me ? :confused:

09-14-2002, 06:37 AM
i dont know anything about cookies but maybe on the split by '=' you should change the $cookies to @cookies, this is more of a random guess. Spell $value the right way.


09-14-2002, 07:30 PM
Just try this Routing.. I use this code all the time. It takes the entire cookie string and breaks it into name/value pairs and puts them in the CookieInfo variable. Easy to refrence by name.

# Get Cookie...
%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;

# this is the value of the cookie nameofcookie
$mycookie=$CookieInfo{'nameofcookie'} ;