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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.