Welcome to WebmasterWorld Guest from 188.8.131.52
I’m a newbie in server side (perl) and I just found out how to deal with cookies. Let me tell you “I’ve discover the wet gun powder”. My new knowledge is great for applications that I was unable to do till now. To be honest, not till now, still having problems.
I can create the cookies and set it in client side, but IE7 do not receive them or does not allow the cookies to be reached. Everything is fine for Mozilla and FireFox about receiving the cookies, even for IE6 cookies are fine, but it doesn’t work with IE7. Beside, the “expire” parameter only works for Mozilla. Firefox and both IE I’ve tried do not seam to respect that. I do not know if this expiration issue is due to the browser or the script, that’s why my help request.
My script to set a cookie is:
$cgi->header( -cookie => new CGI::Cookie(-name => 'MyCookie',
-value => 'This_value',
-expires => '+1h',
-path => ‘\’,
-domain => 'something.com'
Can somebody, please, set some light over this issue?
Why cookies can not be set in IE7 and why some browser do not respect cookies life time?
my $cgi = new CGI;
print $cgi -> header(
-cookie => $cgi -> cookie(
-name => "MyCookie",
-value => "Something",
-path => "/",
-expires => '+1h',
ok, a few notes....
The slash in your path is the wrong way around. Setting a root path is handy so you can use the cookies across the whole site, like with a session cookie.
No need to set the domain really, unless you want the cookie to traverse subdomains which is quite unusual.
The expires +1h is translated by the CGI module into a UTC date string, like "Thu, 17 Sep 2008 17:39:11 UTC". This is what the browser receives. Although I found (with IE, not tested in other browsers), that although the expire time had passed, as long as you hadn't navigated away from the page the cookie was still sent to the server. Best practise is to assign a unique ID, and track it's time on the server, rather than relying on the client to expire.
Now, about cross browser cookies....
There's no such thing. Cookies happen in the HTTP header part of the communication. All browsers and servers handle cookies in the same way.
Hope this helps!
When I set a cookie to expire 1 h after in IE7, the cookie can not be found because it already expired
Yeah that would kill it every time.
Actually there's no way to delete a cookie, the approved way is to give it an expire string in the past!
Although it's very strange that it worked for Mozilla.