How do I remove a cookie that I've set on someone's computer?

I've got a web system where users log in, and it stores a cookie of their session. When they log in as someone else or log out I want to remove that original cookie that I stored. What's the best way to do that? I'm using Python and Apache, though I suppose the answer will remain the same for most languages.

Asked by: Aldus606 | Posted: 27-01-2022

Answer 1

Set the cookie again, as if you hadn't set it the first time, but specify an expiration date that is in the past.

Answered by: Joyce963 | Posted: 28-02-2022

Answer 2

I guess the best way is to set the expiration to a date of the cookie to some date in the past.

Answered by: Lenny896 | Posted: 28-02-2022

Answer 3

Return the header

Set-Cookie: token=opaque; Domain=.your.domain; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/ 

The Domain and Path must match the original attributes that the cookie was issued under.

Answered by: Miranda321 | Posted: 28-02-2022

Similar questions

How do I take Someone's name in Python and create a file to write to with that name?

I am a bit new to Python, and trying to do something simple I'm sure. I want to ask someone their name as the initial raw_input and then I want that name to be used to create a file. This is so that any additional raw_input taken from that user it gets recorded to that file. raw_input("What is your name?") file = open("newfile.txt", "w") I have the above code that will create a file calle...

python - Using how can I get someone's IP when they visit my page

I found this question which seems to be what I'm looking for. It says to use web.ctx['ip'] But I cant get it to work right, all I want is the IP of the visitor in a variable. So far I've been trying this: import web urls = ( '/', 'index' ) class index: def GET(sel...

python - How can i get someone's profile pic on Discord to edit it using PIL?

I'm trying to make some code on python to edit someone's profile pic, but all I've got so far is this: image = background = Apparently that just gets the URL itself, but i need the image itself to edit a picture with PIL. Any insight on how to get it?

How can I get someone's name from a string with regex in python?

string = 'company: / name: James / Street: 24 High Road /' name ='Name:(.*)/(.*)Street:)', string) print(name) I am trying to get 'James' from the string above with regex, but can't find the solution for this. How can I solve this situation with regex?

python - InstaPy bot follow someone's follower problem

I am trying to use instapy bot for automation following follower of someone's instagram per below code. It runs smoothly to login and click into someone profile but cannot find follower link as below feedback. Also 0 follower followed. What is the root cause? Could not find followers' link for 'someone' Grabbed 0 usernames from 'someone's Followers to do following

python - How to input someone's discord tag and getting their user ID in return?

So I have a python program that's gonna take a Discord user's tag and then convert it into the user's ID. How can I do this without needing a Discord bot, and for the person to be in a server with you, etc? My program so far: target = input("") # take the target and print out the target's user id.

Still can't find your answer? Check out these communities...

PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python