我正在使用一些cookie来存储某些部分的状态。 jQuery用于设置cookie。我需要有正确的路径才能删除cookie。这段代码有效,但我提供了路径的值。函数len返回0.如何获取具有路径值的cookie?注销时删除某些cookie
def mylogout(request, next_page=None, template_name=None):
response = render_to_response(template_name,{
}, context_instance = RequestContext(request))
logout(request)
print len(response.cookies.items())
response.delete_cookie('section_body_1', path='/some/url/data/edit/48/')
response.delete_cookie('section_body_2', path='/some/url/data/edit/48/')
response.delete_cookie('section_body_3', path='/some/url/data/edit/48/')
return response
路径无法设置为常量,因为事实证明它有用。我为cookie设置了expires参数,并且我不再为删除而烦恼。 – Seitaridis 2011-01-05 18:14:09