php - Session data not saving -
i debugging php session worked when last tested it, couple of months ago. code has not changed in way, session has stopped working.
i have read multiple questions here other articles no suggestions have solved problem. believe code correct, when asked support @ bluehost, must code problem:
i starting session , setting few session variables:
<?php session_start(); $_session["franchise_name"] = $_post["name"]; $_session["db_name"] = $_post["name"]; $_session["franchise_location"] = $_post["franchise_location"]; $_session["franchise_phone"] = $_post["franchise_phone"]; $_session["franchise_address"] = $_post["franchise_address"]; $_session["franchise_email"] = $_post["franchise_email"]; header("location: session.php"); /* redirect browser */ exit; ?>
if echo session variables after setting them, well. stuff. know works in section.
session.php looks this:
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(e_all); session_start(); echo 'testing output:'; echo session_status(); echo '<pre>'; var_dump($_session); echo '</pre>'; phpinfo(); ?>
so when test this, no data being passed in session. output on session.php is:
testing output:2 array(0) { }
i set tester see if session data enabled:
<?php // start session session_start(); // show banner echo '<b>session support checker</b><hr />'; if (!is_writable(session_save_path())) { echo 'session path "'.session_save_path().'" not writable php!<br />'; } else { echo 'session path "'.session_save_path().'" writable php!<br />'; } // check if page has been reloaded if(!isset($_get['reload']) or $_get['reload'] != 'true') { // set message $_session['message'] = 'session support enabled!<br />'; // give user link check echo '<a href="?reload=true">click here</a> check php session support.<br />'; } else { // check if message has been carried on in reload if(isset($_session['message'])) { echo $_session['message']; } else { echo 'sorry, appears session support not enabled, or php version old. <a href="?reload=false">click here</a> go back.<br />'; } } ?>
the result of test shows session data didn't work here either , session path indeed writable. phpinfo shows sessions enabled.
is there else can try me troubleshoot issue? thanks.
update: did try seeting session path ini_set(' session.save_path','some writable path'); did not solve problem.
from php session_start() page:
note:
use cookie-based sessions,session_start()
must called before outputing browser.
remove spaces before session_start()
, considered output.
update:
it can related location of session files, may try setting new location:
ini_set('session.save_path','/some/safe/path/to/sessions'); session_start();
make sure sessions
has appropriate permissions
Comments
Post a Comment