0

I've been trying to correctly manage sessions throughout the online ordering system I'm writing using PHP. I've got it functioning the way I intended and I allows users to hit the "back" button mid-process, without screwing up the database.

The only thing I do still want, is to prevent the "back" button being used on (or after) the final "All done" screen.

In step 3 (Confirm and proceed) and step 4 (All done), I've included the lines:

session_cache_limiter('nocache');
session_start();

This works perfectly in IE - you see the page confirming your order, but you get a warning if you try to hit "back". The same applies if you navigate on from the site - you can't see the final step.

The same site doesn't seem to work in Safari (5.1.2). I can hit "back" and see all the content that was displayed (it's getting it from a local cache, and not the server).

The site doesn't accept repeated input, so it's not a massive problem, but it's not the functionality I wanted. Does anyone know how to make this work in Safari?

David Fulton
  • 737
  • 7
  • 16

1 Answers1

1

I don't think the problem is the code, but the browser behaviour. In Safari, when you press the back button, it just bring you to the same page you were before, just like you opened the new page in another tab and then closed it, even if you set the cache to ‘no-cache’. In Internet Explorer, on the contrary, when you press back, it takes you to the previous page by pointing to its url and loading it again.

Reading here and there, it seems that there's no way to avoid this behaviour, apart from a little trick, which should force the browser to reload the page when you press back: Preventing cache on back-button in Safari 5.

Community
  • 1
  • 1
entropid
  • 6,130
  • 5
  • 32
  • 45
  • Thanks for this - I didn't think I was doing anything obviously stupid, but couldn't work out why it wasn't working. Happy now you've confirmed it's a browser issue. I've taken a look at the trick you referenced and will try implementing it tonight. – David Fulton Jan 23 '12 at 17:51