PHP is carrying few session variables on next page and leaving few. Following are the 3 session variables i am trying to access on "confirm_cart.php" after redirect. I am getting session values of those variables which are in include file only. print_r($_SESSION) is not printing session variables defined in foo.php <? // file name: foo.php ob_start(); include "include/open_session.php"; @extract($_POST); $_SESSION['txtFName'] = $txtFName; $_SESSION['txtLName'] = $txtLName; $_SESSION['sEmail'] = $sEmail; // print_r($_SESSION); exit(); header ("Location: confirm_cart.php"); ob_end_flush(); ?> PHP: include file(open_session.php) contents: <? session_start(); if(empty($_SESSION['sess_id']) || !isset($_SESSION['sess_id'])){ $sess_id = session_id(); $_SESSION['sess_logedin'] = 0; $_SESSION['sess_id'] = $sess_id; $_SESSION['customer_session_id'] = 0; } ?> PHP: Help me please to solve this issue.
yes session_start(); is on top of confirm_cart.php In fact same include file on top of the confirm_cart.php include "include/open_session.php"; this file has session_start(); at first line. contents of confirm_cart.php include "include/open_session.php"; print_r($_SESSION); // I,m not getting all session variables here //..... more code.... PHP:
Make sure there is no output rendered in any included file and session_start() is not called under any condition. Better write error_reporting(E_ALL); at the top of each script to know what the notice/warning its throwing.
Off the top of my head, I would presume that your output buffering is messing up the session. Try starting the session before ob_start.
I ran your code in my local server and got this as the output. Array ( [sess_logedin] => 0 [sess_id] => ceb9c6ade63363af681d395db864fd8d [customer_session_id] => 0 [txtFName] => [txtLName] => [sEmail] => ) PHP: Its working here.
Thanks xrvel for your time and effort. Thats my problem i am not getting txtFName, txtLName and sEmail on the next page. Array ( [sess_logedin] => 0 [sess_id] => ceb9c6ade63363af681d395db864fd8d [customer_session_id] => 0 ) I am getting only this. Is there something to do with Server/php.ini settings?
What about this : Checking your $_POST with print_r($_POST); PHP: . If you see the data there, check the $txtFName with var_dump($txtFName); PHP: