I have a quick question about session variables. Below is the code I am using to create the session ID. <?php session_start(); if($_REQUEST['id']){ $_SESSION['id'] = $_REQUEST['id']; $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $hidden = "http://" . $host . $uri; //header("Location: " . $hidden); } $id = $_SESSION['id']; ?> Code (markup): I call the ID in a text field when the page loads. "value='<?php echo $_REQUEST['id'];?>" Now, if a visitor navigates away from this page, the value disappears if they return to the page. Is there something I am doing wrong here? I'm assuming it's something simple, but I can't find the issue. I just want the session ID to be stored until the window closes so I can retrieve it in the text field. Thanks in advance for your help.
Yes, I have it in the header. It is passed from a PHP configuration file to the header. Could that be the issue? I am going to try and work through the issue and come up with a solution. I will post it if I find one. Thanks.
Add this line at the top of all your PHP code : <?php $session_length = 60; // 60 minutes session_cache_expire($session_length); ?> PHP:
I think this may have done the trick. I used the original code and simply added the session_length code to the top. Thank you.