Jack Holt wrote:
> Hello there.
> I'm a PHP fan but a Python newbie. I wrote anapplication in Python
> that needs to read a cookie setup from a PHP page. Is itpossible to do it?
> 
> If not, what if I create a TXT file - as well as a cookie - thatcontains
> the cookie's data? Will python be able to open the file and readthe
> data? The TXT file can contain:
> 
> Username = dude
> Password = python

Cookies are sent browser by the web server, and sent back to the web server
by the browser.  So, yes, you can set the cookie with the PHP script and
read it with the python program.

I do it like this:

import Cookie
myCookies = Cookie.SimpleCookie()

if 'HTTP_COOKIE' in os.environ:
    myCookies.load(os.environ['HTTP_COOKIE'])

After that, the cookies will be available via a dictionary style lookup:

user_name = myCookies['user_name']

j



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to