On 2 Jun, 01:13, David Wahler <[EMAIL PROTECTED]> wrote: > 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> > David,
Thanks for your help. I spent all last night trying to get it to work, but I can not work out how to force my cookie into the response header. The most annoying part is on one occasion it did and the cookie sat there until I killed the session. By the time I discovered 'pageinfo' add-in for firefox, the cookie had gone. I have read a lot about cookies, but the grey matter is very slow at absorbing nowadays. I was wondering if I should add the 'path=/' to my cookie, as I am using a host that has numbers for the IP address and my domain name when used, is via a frame. Although the python bit to display the contents (when it did work), did not show any value for 'path'. Could I create the response header in python and get it executed as part of my form submission ? Obviously, still struggling. Richard > 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