|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Clearing cookies
I've got Cookies working fine, keeping track of logged in users on a site, however I am not sure how to delete the cookies if a user wants to log out/user another sign in name. Any help on how I can do this would be great. Thanks in advance
![]() |
|
#2
|
|||
|
|||
|
Hi rebbit.
In order to delete a cookie you need to set the expires attribute in the Set-Cookie header, to date in the past. I attached a small class that I use to write/delete cookies. It works well on IE and mozzila. Hope that helps ![]() Roy Code:
#!/usr/bin/python
class my_cookie:
def __init__(self,name,value):
self.name = name
self.value = value
self.expire = False
def RenderCookie(self):
ret = "Set-Cookie: "+self.name+'='+str(self.value)+';Version="1.0"'
if self.expire == True :
ret = ret+'; expires="Sat,17 Apr 2000 15:17:17 +0000"'
return ret
def ExpireCookie(self):
self.expire = True
def SetValue(self,newVal):
self.value = newVal
def GetValue(self):
return self.value
def GetName(self):
return self.name
|
|
#3
|
|||
|
|||
|
Or if you are using the simplecookie module, just set the "max-age" cookie parameter to a negative value.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Clearing cookies |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|