Re: How to set a cookie using Cookie Module
- From: tryg.olson@xxxxxxxxx
- Date: Thu, 8 Jan 2009 06:39:12 -0800 (PST)
On Jan 7, 9:35 am, tryg.ol...@xxxxxxxxx wrote:
Hello -
This is my first attempt at python cookies. I'm using the Cookie
module and trying to set a cookie. Below is my code. The cookie does
not get set. What am I doing wrong?
print "Cache-Control: max-age=0, must-revalidate, no-store"
print "Content-type: text/html"
print """
<html><head><title>My Page</title>
<link rel=style*** href="/ss.css" type="text/css">"""
c = Cookie.Cookie()
c['MyCookie'] = "Tryg"
print c
If I put javascript code to create a cookie in place of my python
cookie code, the javascript cookie gets set.
Any tips appreciated!
Tryg
I eventually figured it out myself. The cookie code needs to be part
of the HTTP header. See example below.
print "Cache-Control: max-age=0, must-revalidate, no-store"
print "Content-type: text/html"
c = Cookie.Cookie()
c['MyCookie'] = "Tryg"
print c
print """
<html><head><title>My Page</title>
<link rel=style*** href="/ss.css" type="text/css">"""
.
- References:
- How to set a cookie using Cookie Module
- From: tryg . olson
- How to set a cookie using Cookie Module
- Prev by Date: Re: Generator metadata/attributes
- Next by Date: Re: How to set a cookie using Cookie Module
- Previous by thread: How to set a cookie using Cookie Module
- Next by thread: Re: How to set a cookie using Cookie Module
- Index(es):