Forum Moderators: DixonJones
$expDate = "14-June-2001 01:30:45 GMT";
&setCookie("MemberIDLog", $memid, $expDate, $path, $domainc);
sub setCookie {
local($name, $value, $expiration, $path, $domain, $secure) = @_;
print "Set-Cookie: ";
print ($name, "=", $value, "; expires=", $expiration,
"; path=", $path, "; domain=", $domain, "; ", $secure, "\n");
}
It works fine. What do I have to do with headers to set up cookies properly in IE? I know IE is very strict on headers and any help would be greatly appreciated.
I need cookies to track members accessing my site as it is done here on WebmasterWorld server...
Thanks!
Mark.
@cookie_encode_chars = ('\%', '\+', '\;', '\,', '\=', '\&', '\:\:', '\s');
%cookie_encode_chars = ('\%','%25','\+','%2B','\;','%3B','\,','%2C','\=','%3D','\&','%26','\:\:','%3A%3A','\s','+');
@cookie_decode_chars = ('\+', '\%3A\%3A', '\%26', '\%3D', '\%2C', '\%3B', '\%2B', '\%25');
%cookie_decode_chars = ('\+',' ','\%3A\%3A', '::','\%26','&','\%3D','=','\%2C', ',','\%3B',';','\%2B','+','\%25','%');
sub getcookies {
$cookieflag = 0;
my ($cookie,$value,$char);
if ($ENV{'HTTP_COOKIE'}) {
foreach (split(/; /,$ENV{'HTTP_COOKIE'})) {
($cookie,$value) = split(/=/);
foreach $char (@cookie_decode_chars) {
$cookie =~ s/$char/$cookie_decode_chars{$char}/g;
$value=~ s/$char/$cookie_decode_chars{$char}/g;
}
$COOKIE{$cookie} = $value;
}
$cookieflag = 1;
}
return $cookieflag;
}
#---------------------------------------------------------set cookie
#&setcookie("name,value,$expires");
# Set cookie.
# $cookieexp is used in days.
sub setcookie {
my ($cn,$cv,$cexp) =@_;
$ce =$cexp*86400+time if $cexp;
$ce ="" if !$cexp;
print &mycookies_header($ce,$cn,$cv);
}
#---------------------------------------------------------cookies_header
sub mycookies_header {
my ($expires, @cookies) = @_;
my ($header);
my ($cookie,$value, $chr);
my (@days) = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
my (@months) = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime($expires);
$sec= "0".$secif ($sec < 10);
$min= "0".$minif ($min < 10);
$hour= "0".$hourif ($hour < 10);
if ($expires < 1) {
$expires = "";
} else {
$year += 1900;
$expires = "expires\=$days[$wday], $mday-$months[$mon]-$year $hour:$min:$sec GMT;";
}
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;
}
$header.= "Set-Cookie: $cookie=$value; $expires\n";
shift(@cookies);
shift(@cookies);
}
$cookie_out =1;
return $header;
}
-----
#example of setting a cookie:
sub myset_pw_cookie {
print &mycookies_header(time+31536000,"user",$inusername,"pw",$cryptinwd);
}