[Tutor] Cookie help

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Sun Nov 23 17:07:03 EST 2003



On Fri, 21 Nov 2003, Conrad Koziol wrote:

> Hey everyone I'm having some troubles retrieving cookies. The script im
> using is:
>
> #/usr/bin/python
>
> import os
> import Cookie
>
> cookies = Cookie.SimpleCookie()
> cookies.load(os.environ['id'])
> value = cookies['id'].value
> print 'Content-type: text/html\n'
> print value
>
> I set the cookie in another script. They are set as a SimpleCookie with
> the values of username and id. The problem is the script returns an
> error. (I don't quite have access to the error logs, at least yet). Any
> help would be appreciated

Hi Conrad,

I think we'll need better error messages.  Try adding this line right
before the 'import os' line:

###
import cgitb
###

'cgitb' is the 'CGI Traceback' module: if anything bad happens during the
script, cgitb will intercept the error and try displaying a good error
report to your browser.

You can find out more about cgitb here:

    http://www.python.org/doc/lib/module-cgitb.html


Good luck to you!




More information about the Tutor mailing list