Eliminating “Page has expired” warnings

Every programmer working with PHP session cookies has gotten “Page has expired” warnings from time to time. The most common cause is simple: a user, when a session cookie is set, clicks on the Back button. Because the pages are not being cached, the page has, in essence, expired.

As Chris Shiflett points out in his blog post (which you should read after this), the fix is simple. PHP, by default, sends a Cache-Control: nocache header. To override it, set this header in your php.ini file or with a call to ini_set():

1
session.cache_limiter = private

This will cause the server to send a Cache-Control: private header instead. Restart your Web server, and pages will be cached for three hours by default. As always, test that out and see if it causes problems.

Share and Enjoy:
  • email
  • Print
  • PDF
  • Digg
  • del.icio.us
  • Facebook
  • Fark
  • FriendFeed
  • Google Bookmarks
  • HackerNews
  • Identi.ca
  • LinkedIn
  • Live
  • MySpace
  • Ping.fm
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Tumblr
  • Twitter

Tags: ,

7 Responses to “Eliminating “Page has expired” warnings”

  1. Paul Wright says:

    I really enjoy reading your blog. Very informative and inciteful. Excellent Keep up the great work!

  2. illelilop says:

    Hey there everyone i was just introduceing myself here im a first time visitor who hopes to become a daily reader!

  3. Spyprokbroarma says:

    Hey everyone just wanna say hello and introduce myself!

  4. Just want to say thanks for all the great info found on your blog, even helped me with my job recently :) keep it up!

  5. Anonymous says:

    Great blog!!! Very informative and inciteful. Excellent!!!

  6. Anonymous says:

    I like this site very much.

    This is such a great website.
    And it is not like other money oriented site, the information here is very helpful.

    I am definitely bookmarking it as well as sharin it with my friends.

    :)

  7. Eloy Bollin says:

    Great idea this, i like it. Are there any forums that you recommend I join ?

Leave a Reply