...

View Full Version : COOKIES ? cant read them !



quantumpixel
09-12-2002, 07: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 (/;/,
$ENV{'HTTP_COOKIE'});
foreach $cookie (@cookies) {
($name, $vale) = split (/=/,
$cookies);
$crumbs{$name} = $value;

}
}

==

can anyone help me ? :confused:

technophobia
09-14-2002, 05: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.

-Mark

idez
09-14-2002, 06: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'} ;

GOOD LUCK! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum