python - session flush is not working django -


i trying flush session data out when user doesn't want keep logged in.

in views.py

def login(request, *args, **kwargs):     if request.method == 'post':                 if not request.post.has_key('remember_me'):                   request.session.flush()      return auth_views.login(request, *args, **kwargs) 

but when try access site, still shows user user logged in. what's wrong this?

from understand, if user doesn't check remember me - need expire session cookies if user's browser closed.

this can achieved using set_expiry(0):

sets expiration time session. can pass number of different values:

  • ...
  • if value 0, user’s session cookie expire when user’s web browser closed.

usage:

request.session.set_expiry(0) 

see also:


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -