Re: cookie problem - explorer ok, firefox no - FIXED !!




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.

.



Relevant Pages

  • Re: cookie problem - explorer ok, firefox no
    ... login in explorer but in firefox the login data is lost somewhere along ... Unfortunately it didn't fix the problem. ... sub set_cookie { ...
    (comp.lang.perl.misc)
  • Popups and Permissions....
    ... I'm running Windows XP and use Firefox as my primary web ... Windows 6.0 installed and decided to update that to iTunes 7.0. ... prior to installing the new version. ... fix, but can't get anywhere with that. ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Tale of debugging and programming logic in c#/sql
    ... > and I pushed it to production. ... I was anxious to find a fix, ... The login page does ... > user authenticates or creates a new login name -- it is based on an ID ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: IE6 - IE 7 & Hotmail/Windows Live Messenger
    ... I downloaded the IE Tab Extension for Firefox. ... I can still login to ... hotmail/livemail with Firefox - Still cannot get windows updates with Firefox ... In IE7 I CAN log in to the account manager using the link you gave me ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Website works in Firefox not in IE...
    ... Dreamweaver can be a useful tool, but mostly for those who already have good knowledge of HTML. ... Test at least in Firefox, IE7, IE6, and Safari. ... Without looking at it too long, my first suggestion is to fix the syntax errors. ... So fix the validation errors and see what you get in IE then. ...
    (comp.infosystems.www.authoring.html)