Logout and back button w/out sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
turbo2ltr
Forum Commoner
Posts: 29
Joined: Sun Jul 18, 2004 4:08 pm

Logout and back button w/out sessions

Post by turbo2ltr »

I'm using cookies and mySQL, but no sessions to check if a user is logged in. Everything works the way I want it. The problem arises when a user logs out, then clicks the back button. It just reloads the (I assumed cached) "logged in" page. If you refresh it will update and show that you are not logged in.

Is there any way to tell the browser not to use the cached previous page *after* you logout? Or is there another solution to this?

I did a search and only found people with session problems. And the one post I did find that sort of pertained to this didn't have any responses.

Thanks,
Mike
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Try:

Code: Select all

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");
turbo2ltr
Forum Commoner
Posts: 29
Joined: Sun Jul 18, 2004 4:08 pm

Post by turbo2ltr »

Wouldn't this have to but on the page that the user was "back"ing to? And in that case I'd have to have it on every page because there is a logout button on every page. Wouldn't this have a significant impact on image reloading speed?
turbo2ltr
Forum Commoner
Posts: 29
Joined: Sun Jul 18, 2004 4:08 pm

Post by turbo2ltr »

Well, I tried it, and it worked.. didn't seem to effect loading speed too much..Thanks.
Post Reply