Solved: User Log Out and the dang "Back" button!

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

allnodcoms

Thread Starter
Joined
Jun 30, 2007
Messages
613
Hi Guys,

Straight to the point, I'm writing a web app in PHP which requires the user to log in. Everything is hunky dory until they sign out. Well actually, it's hunky dory until they sign out and then hit the back button... Up pops the last HTML rendered page they were on.

I know this is all down to the browser caching, and I've used the PHP 'header()' fuction to set the no-cache and expires params, and I've put the same in the HTML META, but it still displays the damn page... I've killed all the user session values, so they can't navigate away from the page using internal (on-page) links, but basically a copy of the current (or last) user's activity is just sitting there as rendered, client side HTML in the sodding back button! The content of the app isn't likely to bring down governments or threaten life as we know it, but a little security is a good thing...

Basically, I'm a K&R C programmer (hence PHP for the web app) and this data persistence thing is doing my head in. How do other people do this? For my log out I have a link to a php file (not page... no html output) that shuts down the user session, cleans up a bit and redirects to the landing page, but as session stuff is server side, this has no effect on the client side page in the cache. Is there an 'elegant' way of getting round this?

All suggestions found through extensive Googling (I don't Bing) have failed. If it helps, I'm using a local development server to test the app prior to release (MAMP Pro 1.8.2 on Snow Leopard with Safari 4.0.2 - Yes, I use Macs but I'm really an OK guy) so any suggestions welcome - someone must know where I'm going wrong.

Thanks in advance

Danny
 

allnodcoms

Thread Starter
Joined
Jun 30, 2007
Messages
613
You're going to like this one... There was nothing wrong with my code, I checked the page in various browsers and it was only Safari that had the problem. I Googled a bit more and came up with an interesting 'Feature' in WebKit, the framework behind the Safari Browser. Webkit will "Pause" a page when you navigate away from it and, if you decide to go back to it, it just "Presses the Play button...". So, any security checks you place in the onLoad event don't get called as the page is, technically, still loaded. It just jumps backward through your pages, going to the place you were at when you left, and that is pretty obviously long after the onLoad event has been and gone.

Here's the official word: Surfin' Safari.

After a bit of trial and error, I found a way around it. If you do anything at all in response to onUnload (I fire an empty function called doZip();, which does... er... Zip!), Webkit uses conventional caching methods. So it re-loads your page and the onLoad event fires and with it my security checks!

Just thought I'd let you know in case anyone else comes across issues with this useful "Feature" :rolleyes:

Danny
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top