Thank you thorpe for the reply,
Setting the session to 0 is just that I start a javascript timer for e.g 3minutes. Every time the client interacts with login pages (event handlers are used) this timer is reset, if the timer runs out (no events on any of the pages) the page redirects to the login page and unsets the session variables for future usages as described in previouse post.
I did what thorpe suggested, using unset() and checking isset() instead of 0 and 1.
It doesnt seem to work?
Will now try to explain with code.
Assume: You have logged in succesfully -
$_SESSION['logged']= 1;
Now you are directed to "your account"
The initial part of the code is as follows: header functions added as suggested by thorpe
<?
session_start();
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 01 Jan 1980 12:00:00 GMT");
include_once("../checklogged.php");
// other php and then html
....
checklogged.php then looks to see if $_SESSION['logged'] is set or not and does the appropriate redirection if needed.
Initial code for checklogged.php is as follows: showing the if statements and debug code.
<?
session_start();
if(isset($_SESSION['logged'])):
echo "logged is set <br>";
// other code here - load page normally
else:
echo "logged is not set";
//othercode here - redirect to login
endif;
//other if's as above checking other session variables
?>
Uppon loading of "your account" the output: "logged is set" is shown at top of page.
Now you logout. all session variables are set to NULL and unset: example
$SESSION['logged']= NULL;
unset($SESSION['logged']);
And you are redirected to the login page.
If you then press "back" you are shown "your account" again and the output is still
"logged is set" - it didnt revalidate itself, thus seeing that the session variable has been unset. By pressing "refresh" the output then changes to "logged is not set".
This is my problem.
Hope this description is good enough! 🙂
Thank you,