23👍
Closing the tab or window does not count as closing the browser. Make sure you quit the browser program to end a browser session.
If that does not help, use FireBug in firefox or Web Inspector in Safari to double check the headers in the response on your initial page hit. The initial page hit can be one of many things; when you first open the browser, when you logout or immediately after clearing cookies. With SESSION_EXPIRE_AT_BROWSER_CLOSE = True
you should see something like this in the header:
Set-Cookie:sessionid=f4c06139bc46a10e1a30d5f0ab7773e2; Path=/
And when SESSION_EXPIRE_AT_BROWSER_CLOSE = False
an expires=...
value will be added:
Set-Cookie:sessionid=a532f3d7dc314afc58e8f676ed72280e; expires=Wed, 03-Nov-2010 17:08:45 GMT; Max-Age=1209600; Path=/
If you have a hard time seeing the Set-Cookie
header because of redirects you can try using django-debug-toolbar to break the redirects up into multiple pages.
6👍
@istruble and @haasfsafas are both correct. The solution is to
- Set
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
- Delete the rows in the
django_session
table to clear out any sessions that might cause confusion. (delete from django_session
) - Recognize that all of the windows and tabs in your browser must be closed in order for the session to expire. That’s browser behavior; not Django behavior.
- [Django]-Limiting Memory Use in a *Large* Django QuerySet
- [Django]-Django model one foreign key to many tables
- [Django]-Django uploads: Discard uploaded duplicates, use existing file (md5 based check)
- [Django]-Django sitemap http://example.com
- [Django]-No distributions at all found for some package
- [Django]-Get_or_create throws Integrity Error
- [Django]-Query datetime by today's date in Django
- [Django]-How to have two models reference each other Django
- [Django]-How to create a user in Django?
1👍
For anyone who still doesn’t fix the issue after trying all the above solutions, here is one more.
Add this SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
along with the SESSION_EXPIRE_AT_BROWSER_CLOSE = True
It works out for me, good luck folks.
- [Django]-How to check if django template variable is defined?
- [Django]-Redirect to same page after POST method using class based views
- [Django]-Check if model field exists in Django