For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > May 2004 > What could prevent a cookie from being set?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author What could prevent a cookie from being set?
Ingo Weiss

2004-05-22, 11:32 am

Hi all,

I am using CGI to set a cookie:


# create cookie:
$packed_cookie =3D $query->cookie(-NAME =3D> "cookieName",
-VALUE =3D> "cookieValue",
-EXPIRES =3D> "+10m" );
=20
# set cookie: =20
print $query->header (-COOKIE =3D> $packed_cookie);


Now I am experiencin a problem that looks like the cookie is not
being set, but only on specific machines on specific browsers.

What are the factors that could prevent a cookie from being set?

Thanks!
Ingo
Wiggins D Anconia

2004-05-22, 11:32 am

> Hi all,
>
> I am using CGI to set a cookie:
>
>
> # create cookie:
> $packed_cookie = $query->cookie(-NAME => "cookieName",
> -VALUE => "cookieValue",
> -EXPIRES => "+10m" );
>
> # set cookie:
> print $query->header (-COOKIE => $packed_cookie);
>
>
> Now I am experiencin a problem that looks like the cookie is not
> being set, but only on specific machines on specific browsers.
>
> What are the factors that could prevent a cookie from being set?
>


A cookie is simply a standardized header returned before content. I saw
your post on the other list, and the browsers you mention may have not
implemented the standards properly. I would suggest using telnet or an
application that can read raw headers (there is an excellent plugin for
mozilla that does this, but I can't remember its name off the top of my
head, I posted it in a message to this list a while ago), to check what
headers are being printed and to guarantee they look correct. Then
check the browsers where they don't work, and check for known issues
with those browsers and cookie handling. Checking the actual header
will show you exactly how the cookie is attempting to be set and should
reveal if you are doing something wrong, or possibly something the older
browser doesn't understand. Of course if this really is a browser issue
I would suggest you not waste time on it, people need to be using a new
browser preferably one that implements standards corretly, but then I no
longer work professionally as a web developer and now have the luxury of
this attitude ;-)...

http://danconia.org

Ingo Weiss

2004-05-22, 11:32 am

Thanks!

I used the terminal to ssh into my server and run the script from
the command line. This is the output:

"
Set-Cookie: ART635=3Diweiss; path=3D/; expires=3DFri, 07-May-2004
15:28:27 GMT
Date: Fri, 07 May 2004 15:18:27 GMT
Content-Type: text/html; charset=3DISO-8859-1


<?xml version=3D"1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml">
<head>
"
=2E..


Does that look correct?

Ingo






not[color=darkred]
browsers.[color=darkred]
set?[color=darkred]
>=20
> A cookie is simply a standardized header returned before

content. I saw
> your post on the other list, and the browsers you mention may

have not
> implemented the standards properly. I would suggest using

telnet or an
> application that can read raw headers (there is an excellent

plugin for
> mozilla that does this, but I can't remember its name off the

top of my
> head, I posted it in a message to this list a while ago), to

check what
> headers are being printed and to guarantee they look correct.

Then
> check the browsers where they don't work, and check for known

issues
> with those browsers and cookie handling. Checking the actual

header
> will show you exactly how the cookie is attempting to be set

and should
> reveal if you are doing something wrong, or possibly something

the older
> browser doesn't understand. Of course if this really is a

browser issue
> I would suggest you not waste time on it, people need to be

using a new
> browser preferably one that implements standards corretly, but

then I no
> longer work professionally as a web developer and now have the

luxury of
> this attitude ;-)...
>=20
> http://danconia.org

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com