[mod_python] can't seem to expire a cookie value

Necmettin Begiter necmettin.begiter at gmail.com
Tue Jan 22 01:53:33 EST 2008


22 January 2008 Tuesday 04:00:49 tarihinde Matt Barnicle şunları yazmıştı:
> ok i installed the extension and captured some data..  here is what the
> header looks like when i click the signout button:
> 
> Set-Cookie: user_name=matt; expires=Mon, 22-Jan-2007 01:54:01 GMT
> 
> then when i go back to the home page, my code reads the cookies to see if
> the cookie called 'user_name' exists, and if so, logs me in and resets the
> cookies:
> 
> if cookies.has_key('user_name'):
> 	cookie = Cookie.Cookie('user_name', user_name)
> 	cookie.expires = time.time() + 31536000
> 	Cookie.add_cookie(self.req, cookie)

1. Seems you are moving the cookie's expiration date one year forward, not back; you are making 
an addition. Your problem might be this simple.

2. Firefox has an option for keeping cookies until they expire or until Firefox is closed. Check with 
other browsers, too.

3. Keeping login information by just checking for the username is not a good approach. It is 
pretty easy to 'play' with the cookies. You must have at least one other cookie for this (but not 
the password of course).



More information about the Mod_python mailing list