Inserting cookies into a web session

Michael Ströder michael at stroeder.com
Thu Jul 24 02:49:33 EDT 2008


John Gordon wrote:
> I'm developing a web application that needs a semi-persistent way to
> store information.
> 
> I've looked at some options such as writing entries to a database table
> or creating small textfiles, but I'm not thrilled with anything I've come
> up with so far.

What's the problem?

> Then a coworker suggested that I could just insert a cookie into the
> current session, which would store whatever information I wanted.  This
> seems like a really good solution.  That's what cookies are *for*, right?

Before using cookies keep in mind that the cookies returned by the 
browser are not trustworthy! You have to validate the values each time.

> But I've never worked with cookies before.  Is there a Python package for
> handling cookies?

http://docs.python.org/lib/module-Cookie.html

>  And are there any back-end requirements?

No.

>  I assume you
> would have to be running a webserver that supports sessions.

You can do this all within your web application.

>  Do you also
> have to be running some sort of web container or servlet engine?

No.

Ciao, Michael.



More information about the Python-list mailing list