Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Perl + IE + Cookies

by jebusCL (Initiate)
on Dec 06, 2004 at 14:56 UTC ( [id://412658]=perlquestion: print w/replies, xml ) Need Help??

jebusCL has asked for the wisdom of the Perl Monks concerning the following question:

Hi, i'm writing an script that need to register three cookies at the same time from three differents servers located under the same domain. the code that i made works perfectly in Mozilla, but under IE i have the problem that the cookies are overwritten, wich means that only one cookie remains in the client and is the last that i sent. plus, i can't read the cookie written. the script is not CGI the code that i'm using is like this
sub setCookie { my ($expires, @cookies) = @_; my ($header); my ($cookie,$value, $char); my @cookie_encode_chars = ('\%', '\+', '\;', '\,', '\=', '\&', '\:\:', + '\s'); my %cookie_encode_chars = ('\%','%25','\+','%2B','\;','%3B','\,','%2C' +,'\=', '%3D','\&','%26','\:\:','%3A%3A','\s','+'); my @cookie_decode_chars = ('\+', '\%3A\%3A', '\%26', '\%3D', '\%2C', ' +\%3B', '\%2B', '\%25'); my %cookie_decode_chars = ('\+',' ','\%3A\%3A', '::','\%26','&','\%3D' +,'=','\%2C', ',','\%3B',';','\%2B','+','\%25','%'); while(($cookie,$value)=@cookies) { foreach $char (@cookie_encode_chars) { $cookie =~ s/$char/$cookie_encode_chars{$char}/g; $value=~ s/$char/$cookie_encode_chars{$char}/g; } if ( $expires) { $header.= "Set-Cookie: $cookie=$value; expires = $expires; path=/;\n"; } shift(@cookies); shift(@cookies); } $cookie =1; return $header; } sub GetCook { my (@cookies, %cookie_hash, $cookie, $key, $val); @cookies = split (/; /,$ENV{'HTTP_COOKIE'}); foreach $cookie (@cookies) { ($key, $val) = split (/=/,$cookie); $cookie_hash{$key} = $val; } return keys(%cookie_hash); }
where could be the problem?? thanks in advance

Replies are listed 'Best First'.
Re: Perl + IE + Cookies
by dragonchild (Archbishop) on Dec 06, 2004 at 15:15 UTC
    Why aren't you using the methods in CGI::Cookie? Also, if you have three different domains, why aren't you specifying the domain name in the cookie?

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: Perl + IE + Cookies
by csuhockey3 (Curate) on Dec 06, 2004 at 19:46 UTC
    I'm curious why you are not using CGI::Cookie as well, but here is an old non-CGI cookie thread that might help you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://412658]
Approved by Happy-the-monk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-23 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found