Robinson Posted May 12, 2020 Share Posted May 12, 2020 I had set this value into the super global $_SESSION in the first file, file_1.php: <?php //there is some code here $_SESSION['salesorder'] = 'are---io'; //remaining code, includes a form. ?> When the submit button is clicked, the form is submitted to file_2.php <?php //some code over here if (isset($_POST['sales']) && $_POST['sales'] != ""){ $sales = sanitize_input(trim($_POST['sales'])); $_SESSION['salesorder'] = $sales; $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $extra = 'processSO_helper_sd.php'; header("Location: http://$host$uri/$extra?so=".$sales); exit(); } //Begin display include 'inc_fn_header_and_menu.php'; //some code over here ?> which will redirect to processSO_helper_sd.php <?php // Initialize session session_start(); $SD_ID = $_SESSION['salesorder']; $result = $db->query($sql); $row = $result->fetch_assoc(); $rowcount =$row['row_count'];*/ //print_r($_SESSION);//* $result = $tmonedb->query("SELECT COUNT(*) FROM document WHERE SD_ID = $SD_ID")->fetch_array(); $rowcount = $result[0]; //remaining code ?> My problem is that I cannot access the $_SESSION['salesorder'] in the last file processSO_helper_sd.php although I have set it twice previously. I could not add session_start(); in the file_2.php because that was already added in 'inc_fn_header_and_menu.php'; Can someone help me with this? Thank you. Please tell me if you need any additional information. Quote Link to comment https://forums.phpfreaks.com/topic/310756-_session-value-not-being-erased-even-after-logout/ Share on other sites More sharing options...
gw1500se Posted May 12, 2020 Share Posted May 12, 2020 File_1.php has no session_start. File_2.php does not have session_start at the beginning. You need to take it out of 'inc_fn_header_and_menu.php' and put it at the beginning of file_2.php. Quote Link to comment https://forums.phpfreaks.com/topic/310756-_session-value-not-being-erased-even-after-logout/#findComment-1577908 Share on other sites More sharing options...
Robinson Posted May 15, 2020 Author Share Posted May 15, 2020 Okay,But the issue is that the inc_fn_header_and_menu.php file is a shared file, it has been already included in all other files. To remove session_start(). I will have to include session_start() in all those files. Quote Link to comment https://forums.phpfreaks.com/topic/310756-_session-value-not-being-erased-even-after-logout/#findComment-1578012 Share on other sites More sharing options...
gw1500se Posted May 15, 2020 Share Posted May 15, 2020 Then you need to move the include to the beginning of the file. Quote Link to comment https://forums.phpfreaks.com/topic/310756-_session-value-not-being-erased-even-after-logout/#findComment-1578016 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.