• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error Page on clicking back button

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,
On many finanaical websites you might have seen that when a user clicks back button, he is shown an error page and his session gets invalidated. I have some idea that it is done by comparing sessionID/token/someNumber from page to what is there in the server. If they dont match, the session is invalidated.

However I am not able to recall, how exactly is this done. Could you help?

The requirement again: To show an error page to user, when he click back button, and this is to be done by comparing some tokens on the server.

Thanks,
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many ways of doing what you want. One of them is to keep a flag in the session and invalidate the session when the back button is clicked. You can catch the "back button" event using a JS function.

You could also keep the "current displayed" as a String or some ID that represents the page in the session and if the user leaves the page via a browser's button, depending on your business logic, if that's a no-no, you can once again invalidate the session and redirect user to an error page.

Maybe another way would be to alert the user on back button press that if he continues, his session will be invalidated?

You should also check server documentation, there may be already an implemented service .. or some kind of listner that waits for the "back button event" .. and invalidates the session.

I hope this helps
-stan
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never heard of a "back button" Javascript event. There's "onunload" but that catches a LOT more than just the back action. Also, if your solution implements javascript, it will be very simple for anyone familiar with javascript to circumvent the security.

-Yuriy
 
stan ioffe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... Yes, there is no "back button" event per say .. In fact, of the 4 ways i proposed it's the weakest ...
What i meant was that you could implement a "back button" if your application has a button that allows your app to go back .. lol
-stan
reply
    Bookmark Topic Watch Topic
  • New Topic