[mod_python] newbie cookie confusion

Scott Chapman scott_list at mischko.com
Thu Oct 5 17:15:38 EDT 2006


Sells, Fred wrote:
> I've googled but not found this, trying to do cookie example from docs.  The
> output is always of type <type 'str'> and is the cookie name.  How do I get
> value?
> 
> 
> 
> def makecookie(req):
>     c = Cookie.MarshalCookie('spam', 'eggs', 'secret007')
>     d = Cookie.MarshalCookie('xxxx', 'yyy', 'secret007')
>     Cookie.add_cookie(req, c)
>     Cookie.add_cookie(req, d)
>     return 'cookie made'
> 
> def showcookies(req):
>     cookies = Cookie.get_cookies(req, Cookie.MarshalCookie,
> secret='secret007')
>     s = 'There are %s cookies'% len(cookies)
>     for c in cookies:
>         s += '\n%s %s' % (str(c), type(c))
>     return s
> 

I haven't been through the docs but I'd suggest that you have a look at 
cookies[c] in case cookies is a dictionary.

Scott


More information about the Mod_python mailing list