Re: cookie problem - explorer ok, firefox no - FIXED !!
- From: "zorro" <myahact@xxxxxxxx>
- Date: 23 May 2006 17:20:07 -0700
zorro wrote:
Jim Gibson wrote:
In article <1148344478.074060.203600@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
zorro <myahact@xxxxxxxx> wrote:
Hello,
This is my first crack at perl. I know php very well so I agreed to fix
some bugs on a web site and this is a strange one. The problem is i can
login in explorer but in firefox the login data is lost somewhere along
the way and i'm eventually sent back to login. I've narrowed it down to
this piece of code:
foreach (split(/; /,$ENV{'HTTP_COOKIE'})){
($c,$v) = split(/=/);
if($c eq "mycookiename"){
$v =~ s/([a-fA-F0-9]{2})/pack("C", hex($1))/eg;
This line will convert any pair of hex digits to the equivalent
character. This should only be done if the digits are preceded by a %
sign. Therefore, try changing the above line to:
$v =~ s/%([a-fA-F0-9]{2})/pack("C", hex($1))/eg;
if((split(/\|/,$v))[0] ne "NULL"){
($USERname,$USERpass) = split(/\|/,$v);
}
}
}
You're right about the missing %. The many other regexes in the code
have it, so it was a typo. Unfortunately it didn't fix the problem. I
do the exact same steps in IE and in Firefox but Firefox eventually
goes back to the login page and yet the cookie exists in the cache.
Perhaps the cookie-setting code is wrong : ...?
sub set_cookie {
local($z) = unpack('H*',$_[0]);
print "Set-Cookie: mycookiename=$z;";
print " path=/;";
print " expires=Mon, 1-Jan-2030 00:00:00 GMT;";
# print " domain=.coder-world.de;";
print "\n";
}
this is where it redirects to the login page. I enter similar subs on
previous requests and $USERname exists. But then suddenly it exists no
longer, but only when the request is made from Firefox.
sub myfoo {
unless($USERname){
#.... goes here from FIREFOX, even though the cookie is in the cache
print "Location: page.cgi?action=userlogin\n\n";
exit;
}
#.... goes here from IE
}
Ok, i tried setting the domain which the previous coder had commented
and it worked...
My thanks to Jim, the only one who actually offered a real solution.
.
- Follow-Ups:
- Re: cookie problem - explorer ok, firefox no - FIXED !!
- From: Tad McClellan
- Re: cookie problem - explorer ok, firefox no - FIXED !!
- References:
- cookie problem - explorer ok, firefox no
- From: zorro
- Re: cookie problem - explorer ok, firefox no
- From: Jim Gibson
- Re: cookie problem - explorer ok, firefox no
- From: zorro
- cookie problem - explorer ok, firefox no
- Prev by Date: Capture DIE statments from Perl
- Next by Date: Re: Capture DIE statments from Perl
- Previous by thread: Re: cookie problem - explorer ok, firefox no
- Next by thread: Re: cookie problem - explorer ok, firefox no - FIXED !!
- Index(es):
Relevant Pages
|