Jump to content

$_SESSION value not being erased even after logout.

Recommended Posts

I had set this value into the super global $_SESSION in the first file, file_1.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 

//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);
//Begin display
 include 'inc_fn_header_and_menu.php';
//some code over here

which will redirect to processSO_helper_sd.php


// Initialize session

    $SD_ID = $_SESSION['salesorder'];
    $result = $db->query($sql);
	$row = $result->fetch_assoc();
	$rowcount =$row['row_count'];*/
	$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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.