According to Django documentation, "if SESSION_EXPIRE_AT_BROWSER_CLOSE is set to True, Django will use browser-length cookies -- cookies that expire as soon as the user closes his or her browser. Use this if you want people to have to log in every time they open a browser."
And that is what I did by adding the following line to my settings.py file (and restarting the server):
# Close the session when user closes the browser
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
Then I logged into a page which checks if the user is authenticated, and then I closed the browser. When I open my browser again and visit the same page it does not ask for a username and a password because it passes the following test apparently:
def check_teacher(request):
result = {}
if request.user.is_authenticated():
...
What am I doing wrong or what am I missing? Any suggestions?
I'm using Django version 1.3 pre-alpha SVN-13858 on my Ubuntu GNU/Linux 10.10 system and running the above example using the Django development server.