RE: Session issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is this only happening when the user clicks the "back" button in the
browser?

I recently had a similar problem with IE caching pages even when the header
is set to (supposedly) prevent caching.  Apparently there is a bug with IE
which requires a specific workaround.

The fields are pre-filled with the data the user entered (not the session
data; as you said the fields are filled in but the data isn't present in the
$_SESSION array)

Here is the workaround I found which works for my site.  I put this code at
the top of my page, before the call to session_start()

<code>

if(!strpos(strtolower($_SERVER[HTTP_USER_AGENT]), "msie") === FALSE)
{
   header("HTTP/1.x 205 OK");
} else {
   header("HTTP/1.x 200 OK");
}
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, cachehack=".time());
header("Cache-Control: no-store, must-revalidate");
header("Cache-Control: post-check=-1, pre-check=-1", false);

</code>

Once the code is in place, clear your browser cache (temporary internet
files) before testing it or else it may still use the local (cached) copy.

Hope that helps,

Brad

-----Original Message-----
From: Dave Goodchild [mailto:buddhamagnet@xxxxxxxxx] 
Sent: Friday, September 15, 2006 1:01 PM
To: PHP
Subject:  Session issues

Hi all. I am using php sessions in an online events listing to carry around
user data until all data is clean and then entering it into a database after
the final form has been submitted. On the first form the user selects a
category and postcode, and the processing script validates and cleans these
fields and passes them into corresponding session variables, same for 3 more
forms. All works like a dream - until now. Now the user enters the category
and postcode, goes to the next form, and the variables are not there in the
session. I am var_dumping the session at the top of each page to track the
behaviour to see what is happening and it only occurs here - when the user
goes back one page in each case their previously entered values are there
(as I echo the session variable in the fields), but not in the session
array.

Has anyone encountered this kind of problem with sessions before?

-- 
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux