How to set a cookie??? - Newbie question

Randall Kern randy at spoke.net
Wed Nov 15 22:35:33 EST 2000


the syntax of your Set-Cookie header isn't quite right.  Try something like:

s = 'Set-Cookie: Customer=Acme_Coyote; path=/;'
print s

and make sure you do this before you print the blank line separating the
headers from the content; i.e. the Set-Cookie line must be in the header
portion of the HTTP response.

the domain should only be used when you want the cookie to be shared across
several virtual hosts on the same domain, and at least when using netscape
is rather picky.  See
http://developer.netscape.com/docs/manuals/js/client/jsref/cookies.htm for
details.

-Randy

"David Lees" <DavidL.spam.no.no at raqia.com> wrote in message
news:3A12F08A.8ED9C184 at raqia.com...
> I am executing a small python program from cgi-bin and want to set a
> cookie in the users browser.  Does someone have a simple example of
> this?  I have tried the simple way:
>
> s='Set-Cookie: domain=192.168.0.13; Customer=Acme_Coyote'
> print s
>
> This gets executed without error, but there must be something else that
> needs to go into the string or some Python method for sending this
> properly to the browser so that it actually places the cookie.
>
> Thanks in advance.
>
> david lees
>





More information about the Python-list mailing list