Working Python Cookies code.

PiedmontBiz piedmontbiz at aol.com
Fri Feb 27 16:09:59 EST 2004


Greetings

I am working on web site (class project) which has a personality assessment
survey section. I originally wrote a standalone program in RapidQ basic. I
decided to rewrite the program for the web using python. I use Javascript on
the client side and two python scripts on the back side.

Problem. It would have been very easy (I think) if I could have gotten my
python script to read and write cookies . I am a newbie to python. I am not
able to make any of the code snippets work. I have tried.

   the examples in the python23 documentation (cute code but useless to me)
   ug's Python CGI scripts: cookie.py (compiler balks, throws exceptions)
   Danny Yoo's script hkn.eecs.berkeley.edu/~dyoo/python/cookiecounter.py

I finally got it to work by just using javascript to call the script and pass
the form
  eg.  ( http://www.expectedend.com/cgi-bin/gq.py?QuestionNum=123)

this works, but the final screen of the program -- 110 python-generated pages
total-- contains a key value 110 characters long.

example session: 
"http://www.expectedend.com/cgi-bin/testresults.py?SG=31234210123324213133
21401341031331234101233123143104321000011222222222222233333333333333344444
444443333400030249"

I suppose a user might be concerned to see this large url in his/her address
window.  

Does anyone have a working cookie snippet which would only use standard Python
2.3+ libraries and not require anychanges to Apache or any binary dependencies?

Or, is my solution good enough.

Thanks in advance.


Allen





More information about the Python-list mailing list