On Jun 1, 3:49 pm, mosscliffe <[EMAIL PROTECTED]> wrote: > I have the following code, which I thought would create a cookie, if > one did not exist and on the html form being sent to the server, it > would be availabe for interrogation, when the script is run a second > time. > > It seems to me there is something basic missing in that I should need > to tell the server I am sending a cookie, but all the docs I have read > imply it is done automatically, if one creates a 'Cookie.SimpleCookie' > > I know my understanding is poor of web server logic, but if anyone can > help, I will be most grateful. > > This may be more to do with Web Server behaviour than python > programming, but surely there is a way of doing this in python. > <snip code>
The cookie values have to be sent to the browser as part of the response headers. (Modifying the Cookie object doesn't do this for you -- the Cookie instance just acts as a container.) In other words, something like this: c = Cookie.SimpleCookie() c.load(os.environ['HTTP_COOKIE']) # ...modify cookie object... print "Content-Type: text/html" print c print # send the HTML text -- David -- http://mail.python.org/mailman/listinfo/python-list