I want to delete all cookies for the user under my domain name. I know logout()
method removes the session, but it seems like some of my apps are generating a few more cookies that needs to be cleansed. How can I achieve this?
Asked
Active
Viewed 1.4k times
5
-
8Sorry but this was just perfect: http://farm3.static.flickr.com/2359/2534644455_4cb78c0d2c.jpg – Travis Feb 19 '10 at 21:25
-
2possible duplicate of [Django logout(redirect to home page) .. Delete cookie?](http://stackoverflow.com/questions/1275357/django-logoutredirect-to-home-page-delete-cookie) – Olli Feb 11 '14 at 14:10
-
1Not a duplicate, since that question asks about a single cookie, not all cookies. – Tyson May 25 '18 at 02:12
2 Answers
0
This is a late answer, but:
def some_view(request):
response = HttpResponseRedirect('/any-page-you-want/')
for cookie in request.COOKIES:
response.delete_cookie(cookie)
return response

Sid
- 2,174
- 1
- 13
- 29