Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 4th, 2004, 08:16 PM
rebbit rebbit is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 84 rebbit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 7 m
Reputation Power: 5
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

Reply With Quote
  #2  
Old July 4th, 2004, 08:58 PM
roypython roypython is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 71 roypython User rank is Lance Corporal (50 - 100 Reputation Level)roypython User rank is Lance Corporal (50 - 100 Reputation Level)roypython User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 h 20 m 49 sec
Reputation Power: 5
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


Reply With Quote
  #3  
Old July 5th, 2004, 03:50 PM
ilves ilves is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Norway
Posts: 41 ilves User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 22 sec
Reputation Power: 6
Or if you are using the simplecookie module, just set the "max-age" cookie parameter to a negative value.
__________________
Good web hosting info - articles about web hosting
hb's web dev blog

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Clearing cookies


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway