Expire header problem with sessions

From: Date: Fri, 08 Sep 2000 19:16:20 +0000
Subject: Expire header problem with sessions
Groups: php.dev 
Request: Send a blank email to php-dev+get-32724@lists.php.net to get a copy of this message
I'm trying to get sessioned pages to be cached for at least a short period of time. I have set session.cache_limiter = private and session.cache_expire = 1 in my php.ini file. I would expect that the Expire header would be updated according to the cache expire time, but it is not. I would even be happy if an expire header output with header() would override the one sent by PHP4's session management, but it does not. Could the following code in session.c be updated to pay attention to cache_expire instead of outputting a hardcoded expire time? CACHE_LIMITER_FUNC(private) { char buf[MAX_STR + 1]; ADD_COOKIE("Expires: Thu, 19 Nov 1981 08:52:00 GMT"); sprintf(buf, "Cache-Control: private, max-age=%ld, pre-check=%ld", PS(cache_expire) * 60, PS(cache_expire) * 60); ADD_COOKIE(buf); last_modified(); } With my counter example below, the desired behavior is for the counter to increment each time I hit the reload link, but still allow a Netscape browser to use the back button to get to cached pages with previous counter values. Currently when you hit the back button the counter increments because the page hasn't been cached and you again hit the server. (BTW, Internet Explorer ignores the past Expire time and caches the pages.) Example: php.ini ======= ... session.cache_limiter = private ; session.cache_expire = 1 ; document expires after n minutes ... counter.php =========== <?php header("Expires: " . gmdate("D, d M Y H:i:s", time()+(60)) . " GMT"); session_start(); if(!session_is_registered('counter')) { session_register('counter'); } $counter++; echo "Counter: $counter<p>\n"; echo '<a href="'. $PHP_SELF. '?'. uniqid(''). '">Reload</a>'; ?> lynx --head --dump http://localhost/test/counter.php HTTP/1.1 200 OK Date: Fri, 08 Sep 2000 18:27:52 GMT Server: Apache/1.3.12 Expires: Thu, 19 Nov 1981 08:52:00 GMT Set-Cookie: PHPSID=6a46d51d9fd4b82a8cad5db00bdc20e7; path=/ Cache-Control: private, max-age=60, pre-check=60 Last-Modified: Fri, 8 Sep 2000 18:18:02 GMT Connection: close Content-Type: text/html

« previous php.dev (#32724) next »