Hi all,
I have an odd problem with retrieving a cookie.
1. I set the cookie as such:
print "Set-cookie: cookieName=3; " . $HTMLHEADERS
The HTMLHEADERS var contains the Content-type: statement and other general formatting. I'm almost positive that it's being set correctly.
2. I retrieve the cookie from another page as such:
sub get_cookie{ #credit given to this forum and 'pump' for
#the routine
local($chip, $val);
foreach (split(/; /, $ENV{'HTTP_COOKIE'})){
#i'm using solaris so the env var should work fine
s/\+/ /g;
($chip, $val) = split(/=/, $_,2); #split on first '='
#now convert hex to ascii
$chip =~ s/%(A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
$val =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
# Associate key and value
$cookie{$chip} .= "\1" if (defined($cookie{$chip}));
# \1 is the multiple separator
$cookie{$chip} .= $val;
}
}
3. I print the value of the cookie as such:
print "<P>Cookie Value: " . $cookie{'cookieName'} . "</P>";
4. And here comes the question:
The html page displayed shows the following
Cookie Value: 33
So where on earth did that box thing and the repeated value come from and how do I rid myself of it? Any help or thoughts would be greatly appreciated as I am at my wits end on this one. Thanks.
Mike
~~~~
simanek@uiuc.edu
"It's a Swingline!"
~~~~
I have an odd problem with retrieving a cookie.
1. I set the cookie as such:
print "Set-cookie: cookieName=3; " . $HTMLHEADERS
The HTMLHEADERS var contains the Content-type: statement and other general formatting. I'm almost positive that it's being set correctly.
2. I retrieve the cookie from another page as such:
sub get_cookie{ #credit given to this forum and 'pump' for
#the routine
local($chip, $val);
foreach (split(/; /, $ENV{'HTTP_COOKIE'})){
#i'm using solaris so the env var should work fine
s/\+/ /g;
($chip, $val) = split(/=/, $_,2); #split on first '='
#now convert hex to ascii
$chip =~ s/%(A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
$val =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
# Associate key and value
$cookie{$chip} .= "\1" if (defined($cookie{$chip}));
# \1 is the multiple separator
$cookie{$chip} .= $val;
}
}
3. I print the value of the cookie as such:
print "<P>Cookie Value: " . $cookie{'cookieName'} . "</P>";
4. And here comes the question:
The html page displayed shows the following
Cookie Value: 33
So where on earth did that box thing and the repeated value come from and how do I rid myself of it? Any help or thoughts would be greatly appreciated as I am at my wits end on this one. Thanks.
Mike
~~~~
simanek@uiuc.edu
"It's a Swingline!"
~~~~