Logout implementation Django

98 views
Skip to first unread message

palansh agarwal

unread,
Oct 14, 2015, 5:07:07 AM10/14/15
to Django users
Hi,

I am trying to implement logout for users in my app. My problem is : When a user logs out and clicks back button in browser he is able to access the website again without logging in.

My current code for logout function is-->

def logout_user(request):
    del request.session['userid']
    logout(request)
    return render_to_response('index.html')

Any help will be appreciated.

Regards,

Andreas Kuhne

unread,
Oct 14, 2015, 8:46:18 AM10/14/15
to django...@googlegroups.com
Hi,

You should be able to access the website without logging in? Or do you mean that the user has access to protected pages? 

If you have added the login_required decorator (https://docs.djangoproject.com/en/1.8/topics/auth/default/#the-login-required-decorator) on your view functions that shouldn't be possible. However the cached version of the page should still be accessible (by clicking back). That is per design (the client side caches the page). You can prevent this by using cache decorators: http://stackoverflow.com/questions/6923027/disable-browser-back-button-after-logout

Regards,

Andréas

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/183577c1-57b8-47be-9308-19205cb11bd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

palansh agarwal

unread,
Oct 14, 2015, 9:12:11 AM10/14/15
to django...@googlegroups.com
Thank you. The problem with the cache thing. Now resolved.

Palansh Agarwal | +919461787317
Co-Founder, Team Lead IDC, GoMobileFirst, USA
Systems/Software Dev InternInstaroid , Bangkok, Thailand
Pre Final Year, B.Tech
The LNM Institute of Information Technology, Jaipur, India
https://www.facebook.com/palansh.agarwal      https://github.com/py-geek  palansh

See! it's not hard when you FOCUS

Reply all
Reply to author
Forward
0 new messages