3 Replies - 4004 Views - Last Post: 15 June 2011 - 06:30 AM

#1 teahou  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 223
  • Joined: 01-April 11

Disable browser back button after logout

Posted 14 June 2011 - 06:34 PM

Howdy. I was wondering how to stop the browsers back button from working after a user has logged out. I tried the windows.history.forward(1); function but it either is not working for me, or I am not putting it int the right place.

The logout button is on the menu.php page. The button calls the logout.php file which redirects the user to the index.php page after logout.

Any hints or a good tutorial would be great, thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Disable browser back button after logout

#2 psyking  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 20
  • View blog
  • Posts: 165
  • Joined: 17-January 10

Re: Disable browser back button after logout

Posted 14 June 2011 - 06:40 PM

You could try sending to them to the login page if they try to access a page that requires them to be logged in?
Was This Post Helpful? -1
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,324
  • Joined: 08-June 10

Re: Disable browser back button after logout

Posted 14 June 2011 - 10:34 PM

I wouldn’t bother with that, if the user is logged out, every access to one of the restricted pages should redirect him to the login page.
Was This Post Helpful? 0
  • +
  • -

#4 anonymouscodder  Icon User is offline

  • member icon

Reputation: 126
  • View blog
  • Posts: 710
  • Joined: 01-January 10

Re: Disable browser back button after logout

Posted 15 June 2011 - 06:30 AM

You can't disable the back button. I guess you can't either mess up the browser history (window.history).

I tried:
<!-- a.html -->
<script>window.location.href = './b.html';</script>


On FF 3, a.html doesn't show up in the history, guess they prevent the user from being trapped. On IE 8, the user have to manually allow the execution of this, then a.html redirects to b.html and the a.html is the first page on the back button. Terrible solution, the user is just trapped (back button keep redirecting to b.html).

The real problem is caching. You can add the meta tag:
<meta http-equiv="Pragma" content="no-cache" />

But you can prevent cache better at server-side.

This post has been edited by anonymouscodder: 15 June 2011 - 06:31 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1