Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User login session ends with browser closing

Tags:

django

Django has authentication module, which works great. There is little problem that once user is loged in, that information is saved for longer period of time. Even user close browser session do not end. Actually, I want that session to end when user close browser.

Is there any way that user's login information is no longer remember once browser is closed

Krish

like image 802
Elisa Avatar asked Sep 19 '11 16:09

Elisa


People also ask

Does session end when browser closed?

Browsers deletes the session cookies when the browser is closed, if you close it normally and not only kills the process, so the session is permanently lost on the client side when the browser is closed.

How long does a user session last?

By default, a session lasts until there's 30 minutes of inactivity, but you can adjust this limit so a session lasts from a few seconds to several hours.

What is a user login session?

In computing, a login session is the period of activity between a user logging in and logging out of a (multi-user) system.


2 Answers

Use this in settings.py:

SESSION_EXPIRE_AT_BROWSER_CLOSE = True
like image 74
Gabriel Ross Avatar answered Sep 30 '22 21:09

Gabriel Ross


alternatively you can pass 0 in

set_expiry(0)

just like this:

request.session.set_expiry(0)

like image 25
S.Ali Avatar answered Sep 30 '22 19:09

S.Ali