cherrypy.response.simpleCookie["name"]=name
and when the user click logout , I should remove the cookie data. I write below code:
@turbogears.expose()
def loginout(self):
hasname=False
for key,item in cherrypy.request.simpleCookie.items():
if key == "name": #get a cookis
#cherrypy.response.simpleCookie["name"]["expires"]=0
hasname=True
break
if hasname==True:
cherrypy.response.simpleCookie.clear()
turbogears.flash("you are login out!")
raise cherrypy.HTTPRedirect (turbogears.url("/index"))
#there is no name cookie
else:
turbogears.flash("you are not login!")
raise cherrypy.HTTPRedirect(turbogears.url("/index"))
Then when I click logout,the server produces something:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py", line 271, in run
main()
File "/usr/lib/python2.4/site-packages/CherryPy-2.1.1-py2.4.egg/cherrypy/_cphttptools.py", line 502, in main
body = page_handler(*args, **cherrypy.request.paramMap)
File "/usr/lib/python2.4/site-packages/TurboGears- 0.8.9-py2.4.egg/turbogears/controllers.py", line 124, in newfunc
output = func(self, *args, **kw)
File "/home/ye/logintest/logintest/controllers.py", line 82, in loginout
cherrypy.response.simpleCookie ["name"]["expires"]=0
KeyError: 'name'
what is problem? I check that simpleCookis do have the name key.....
Please help me!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

