steonkeys Posted September 25, 2007 Share Posted September 25, 2007 Hi, I wonder if you could help me, as I can't see where I'm going wrong. I have got an area of my website that is password protected. tGateway.php gets the user to input the password then checks, then if it is correct, sets a session variable - $_SESSION['trainee'] = 1; and then redirects to another page. (tGPS.php) This works fine, the problem occurs when i then go from this page to any other page in the protected area. It kicks me out and takes me back to the password screen - as it is meant to do, if $_SESSION['trainee'] != '1'; So some how, the trainee variable it being reset to 0, I've done print variable on the tCP.php page without the if statement and it's claiming that the variable is 0. I can't see how it's reset it's self, and more the to the point how to stop it! There is not any other php code in the pages. See below for the php code of each page. Thank you in advance. Steven tGateway.php (password form) <?php session_start(); if ($_POST['password'] == 'password') //not real password - I ain't that stupid { $_SESSION['trainee'] = '1'; header("Location: http://www.gahp.co.uk/scitt/tGPS.php"); } ?> tGPS.php (this one works fine - trainee is set to 1) <?php session_start(); if ($_SESSION['trainee'] != '1') {header("Location: http://www.gahp.co.uk/scitt/tGateway.php"); } ?> tCP.php (this one doesn't work - trainee is some how set to 0 - but it shouldn't be) <?php session_start(); if ($_SESSION['trainee'] != '1') {header("Location: http://www.gahp.co.uk/scitt/tGateway.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/70613-session-variables/ Share on other sites More sharing options...
localhost1 Posted September 25, 2007 Share Posted September 25, 2007 i think u have to check the directroy where u have stored the session variables Quote Link to comment https://forums.phpfreaks.com/topic/70613-session-variables/#findComment-354829 Share on other sites More sharing options...
steonkeys Posted September 25, 2007 Author Share Posted September 25, 2007 ? what you mean check directory? Quote Link to comment https://forums.phpfreaks.com/topic/70613-session-variables/#findComment-354869 Share on other sites More sharing options...
HuggieBear Posted September 25, 2007 Share Posted September 25, 2007 I can't see anything wrong with the code you posted. Maybe it's somewhere in the code you haven't posted. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70613-session-variables/#findComment-354895 Share on other sites More sharing options...
steonkeys Posted September 25, 2007 Author Share Posted September 25, 2007 i can't see anything wrong with it either, thats the annoying thing!! Quote Link to comment https://forums.phpfreaks.com/topic/70613-session-variables/#findComment-354933 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.