Welcome to WebmasterWorld Guest from 54.147.10.72

Forum Moderators: DixonJones & mademetop

Message Too Old, No Replies

Cookies and how to post set them in IE?

I am having trouble setting them in IE...

     

lak12

2:02 am on Jun 15, 2001 (gmt 0)

10+ Year Member



Hi to all of you!
Well, I guess subject pretty much describes my problem. To be specific I am setting up cookies OK in Netscape using Perl as (just and example):

$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.

Brett_Tabke

4:47 pm on Jun 15, 2001 (gmt 0)

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



#---------------------------------------------------------GetCookies
# Get cookies.

@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);
}

lak12

10:41 pm on Jun 15, 2001 (gmt 0)

10+ Year Member



Thanks Brett!
Sometimes it takes tooo long to figure/find/work-out something that you need. Thanks. You saved me a day and I owe you one :-))
Regards.
Mark.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month