http://www.perlmonks.org?node_id=412658

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