Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Perl + IE + Cookies

by jebusCL (Initiate)
on Dec 06, 2004 at 14:56 UTC ( #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

Comment on Perl + IE + Cookies
Download Code
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
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? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2015-07-07 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls