Cookie Problem

Chris Angelico rosuav at gmail.com
Wed Aug 10 21:46:23 EDT 2011


On Thu, Aug 11, 2011 at 12:39 AM, Jack Hatterly
<jackhatterly at hotmail.com> wrote:
>     cookie['lastvisit'] = str(time.time())
>     cookie['lastvisit']['expires'] = 30 * 24 * 60 * 60
>     cookie['lastvisit']['path'] = '/var/www/html/my_site/'
>     cookie['lastvisit']['comment'] = 'holds the last user\'s visit date'
>     cookie['lastvisit']['domain'] = '.www.my_site.com'
>     cookie['lastvisit']['max-age'] = 30 * 24 * 60 * 60
>     cookie['lastvisit']['secure'] = ''
>     cookie['lastvisit']['version'] = 1

Some of these values look wrong. Your 'path' ought to be as the
browser sees it, and your 'domain' ditto; the only way that these
would make sense is if you're setting this cookie on a page such as:

http://foo.www.my_site.com/var/www/html/my_site/blah/blah

and you want to also see the cookie on the page:

http://bar.www.my_site.com/var/www/html/my_site/asdf/qwer

Otherwise, I would recommend omitting those elements and allowing the
defaults through.

ChrisA



More information about the Python-list mailing list