I'm new to php and I'm building a site but the problem I'm facing is that I want to restrict the users to go back after logout. By this I mean to say that whenever user clicks on logout button it is redirecting to login page but even after logout if users click on back button it is redirecting the user to the last page they had visited which I don't want. I tried searching but didn't got any result.
Can anyone help me on how to resolve that problem and please if anyone is giving codes then please tell me where to put that code also..
Thank you..
How to restrict user to go back after logout in php?
Moderator: General Moderators
-
VikramShaw
- Forum Newbie
- Posts: 3
- Joined: Sun Jul 05, 2015 3:32 pm
Re: How to restrict user to go back after logout in php?
You can't really prevent people from doing that.
What's the problem with them going back?
What's the problem with them going back?
-
VikramShaw
- Forum Newbie
- Posts: 3
- Joined: Sun Jul 05, 2015 3:32 pm
Re: How to restrict user to go back after logout in php?
There are two ways of preventing that:- 1) By killing the session after users clicks on logout and 2) By removing the cache from user side(which is not recommended). But the thing is I don't know how to do it.
For security purpose I need that.
For security purpose I need that.
Re: How to restrict user to go back after logout in php?
So you don't mind if they go back - you just don't want to show the content? Of course they could still File > Save the page...
There are some cache headers to include to prevent caching, primarily Cache-Control and Pragma. Send those (with the appropriate values) on that page and the browser should always attempt to re-request the page, both on refresh or back button.
There are some cache headers to include to prevent caching, primarily Cache-Control and Pragma. Send those (with the appropriate values) on that page and the browser should always attempt to re-request the page, both on refresh or back button.
-
VikramShaw
- Forum Newbie
- Posts: 3
- Joined: Sun Jul 05, 2015 3:32 pm
Re: How to restrict user to go back after logout in php?
Sorry to say but I didn't understood what you told.
See I'm building a social networking site and the only thing which is creating prob is this.
I want if user click on logout it should redirect to login page which is working fine but after logout if they press browser back button it should not redirect to the last page they had visited rather it should refresh the login page so that they can't access the last page they had visited.
See I'm building a social networking site and the only thing which is creating prob is this.
I want if user click on logout it should redirect to login page which is working fine but after logout if they press browser back button it should not redirect to the last page they had visited rather it should refresh the login page so that they can't access the last page they had visited.
Re: How to restrict user to go back after logout in php?
Look into those headers I mentioned and make sure they get sent on each page, either by way of server configuration or by PHP's header(). They tell the browser not to cache pages. Thus when the user hits Back or whatever, the browser will request the page from your server and you can tell it to redirect.