Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi

 

When I get the Chapter 16 example up and running I noticed the following:

 

If I login from the index page, I get the “Welcome to this site” page – as expected. The navigation links now show “logout” as one of the options.

If I then hit the back button on my browser, it takes me back to the login page, again as expected. There is no change to the links, though. So I now have a logout and change password link on the navigation list) but a login main page.

 

Any ideas for how I can get over this? Is it a security risk? I tried the same on amazon, where I seemed to be instantly logged out when I hit the back button, which I guess may be better from a security point of view…

 

I am implementing my own site now, so the security side is paramount for me.

 

Any help appreciated.

Link to comment
Share on other sites

It's not a security risk, it's a caching issue. When you click "back", the browser tries to reload the previously-cached version. To force the page to be reload, you'll need to send "no cache" headers. I don't have the code off the top of my head, but I think it may be on the PHP manual page for the header() function.

Link to comment
Share on other sites

header("Last-Modified: Wed, 23 Mar 2011 21:42:00 GMT");
header("Expires: Tue, 22 Mar 2011 21:42:00 GMT");
header("Pragma: no-cache");
header("Cache-Control: no-cache");

 

Here's the code from Larry's PHP 5 Advanced for ensuring a page is not cached by browsers, servers etc... But like Larry says it's no a security issue to worry about.

  • Upvote 1
Link to comment
Share on other sites

Thanks for the interest in the book. The publisher has just agreed to a third edition of that book, but no deal is in place yet, so it'll be probably a year from now before the third edition is out. If you want to buy the 2nd edition now, I'll go ahead and offer you a free copy of the third edition when it is released.

Link to comment
Share on other sites

Thanks! When the third edition of the book comes out, just send me an email and remind me of this conversation. If you subscribe to the newsletter, you'll be notified of the book's status that way. To be clear, I don't even have a deal yet for this book, but the publisher is interested.

 

Thanks for trying to credit me through the link, too. Not sure if that'll work, but I appreciate the effort (I'm generally opposed to advertising, but that Amazon widget is just about covering the cost of my hosting).

Link to comment
Share on other sites

 Share

×
×
  • Create New...