Skip to content Skip to sidebar Skip to footer

How To Set Session Not To Expire On Browser Close In Django?

How to set the session not to expire on browser close in Django? I created cookie with expiry days: In setting.py I added SESSION_EXPIRE_AT_BROWSER_CLOSE = False and SESSION_COOKIE

Solution 1:

Try this

def login(request, *args, **kwargs):
    if request.method == 'POST':  
        request.session.set_expiry(settings.LOGIN_SESSION_TIMEOUT) 
        settings.SESSION_EXPIRE_AT_BROWSER_CLOSE =  False      
    return auth_views.login(request, *args, **kwargs)

Post a Comment for "How To Set Session Not To Expire On Browser Close In Django?"