-2

How to disable the browser backbutton after signout / logout for my website. I am using jsp and struts1, i am using this code but this is not working properly (i.e in all pages the browser backbutton is not working but my requirement is was not that one) .

    <script>
        history.forward();
    </script>

Please any one help me.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
chakri
  • 629
  • 3
  • 11
  • 21
  • @TJ its using javascript, but i want to do it in java, so why it is duplicat of that one – chakri Jun 17 '14 at 12:19
  • java runs on a server. back button is on your client. (browser). if there's no option for closing called *this doesn't make sence* . Also, if you don't want to do it using javascript, then why did you **tag** javascript..? – T J Jun 17 '14 at 12:22
  • @TJ, ok,i agreed your point, i am new for stackoverflow .., Thanks for your valuable reply – chakri Jun 17 '14 at 12:29
  • You need to set no-cache headers so the page will not be cached. If its cached then it might be available still. – developerwjk Jun 17 '14 at 13:33
  • try some spring- security type framework. it is useful in security wrapping application resources. – Gnanz Oct 14 '14 at 07:40

1 Answers1

4

You don't need to disable the browser back button. You need to expire/invalidate the session when the user clicks logout. Then even if he clicks the back button, your app should detect that this request now comes with an invalid session, and so it would forward him to the login page (as he has no valid session already).

peter.petrov
  • 38,363
  • 16
  • 94
  • 159