GarethB Posted November 28, 2011 Share Posted November 28, 2011 Hi, I have a feeling that this is going to be an easy miss but I've been over is a good few times and cannot see what it could be. Essentially, when I post the form in the first set of code (I've got rid of a load of unecessary html) the SESSION variables are not loaded into the second piece of code. Any ideas? <?php session_start(); require ("connect.php"); $timeout = 1800; $logout_redirect_url = "login.php"; if (isset($_SESSION['start_time'])) { $elapsed_time = time() - $_SESSION['start_time']; if ($elapsed_time >= $timeout) { session_destroy(); header("Location: $logout_redirect_url"); } } $_SESSION['start_time'] = time(); ?> <div id="leftlink"> <a href="logout.php">Logout</a> </div> <table align="center" width="600px" cellpadding="0" cellspacing="0"> <tr> <td> <h2 align="center"><a href="index.php"><img src="images/logo.jpg" border="0" /></a> <br /> Emergency</h2> <hr /> </td> </tr> </table> </head> <body> <form action="post_reset.php" method="post" name"passre"> <table width="500" border="0" align="center" cellpadding="2" cellspacing="1"> <tr> <td width="230"><div align="right">E-mail Address : </div></td> <td width="40"> </td> <td width="230"><div align="left"> <input name="email" readonly="readonly" value="<?php echo ($_SESSION['email']) ; ?>" /></div></td> </tr> <tr> <td colspan="3"><div align="center"><input type="submit" name="submit" value="Submit" /></div></td> </tr> </table> </form> </body> </html> <?php session_start; echo ($_SESSION['start_time']); require ("connect.php"); if (isset($_POST['submit'])){ $email = $_POST['email']; $getde = "SELECT * FROM users WHERE email = '$email'"; $getder = mysql_query($getde, $conn); $getdere = mysql_fetch_array($getder) Thanks Gareth Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted November 28, 2011 Share Posted November 28, 2011 you have session_destroy() in your first bit of code, which destroys the entire session, including $_SESSION['start_time']. Quote Link to comment Share on other sites More sharing options...
GarethB Posted November 28, 2011 Author Share Posted November 28, 2011 Hi, The session_destory(); only comes into play when the user has timed out after 30 mins. Later on the first piece of code, I call a Session variable ( $_SESSION['email'] ) which is displayed no problems. Cheers Gareth Quote Link to comment Share on other sites More sharing options...
GarethB Posted November 28, 2011 Author Share Posted November 28, 2011 Sorry my bad I'm being a twonk - I missed the () from the session_start on the second piece of code. I need to goto bed...! Thanks Quote Link to comment 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.