[mod_python] Making cookies live byind the current session

Jakob Simon-Gaarde jakob at simon-gaarde.dk
Mon Apr 26 20:26:16 EST 2004


Hi mod_python experts.

I have a problem storing cookies beyond the the session in which they 
are stored. After the first part of code has been run I can see in the 
browsers cookiebrowser that the cookie is available, but if I then close 
the browser and browse the cookeis again it is gone!

The cookie readerpart also works fine until the browser is closed.

What am I doing wrong?

= In the file where I store th cookie =========
   # Store a cookie
   value = {'holdid': int(holdid)}
   Cookie.add_cookie(req, Cookie.MarshalCookie('fodbold',
                     value,'secret007'),expires=time.time()+3600*24*330)

   cookies = Cookie.get_cookies(req, Cookie.MarshalCookie,
                                   secret='secret007')
===============================================


= In another file I read the cookie ===========
   # Read cookie
   if cookies.has_key('fodbold'):
     fodboldcookie = cookies['fodbold']

     if type(fodboldcookie) is Cookie.MarshalCookie and \
        fodboldcookie.value.has_key('holdid'):
       holdid=fodboldcookie.value['holdid']
===============================================



More information about the Mod_python mailing list