PHP Session Not Saving

PHP Session not Saving

Your session directory (probably /tmp/) is not writable.

Check with session_save_path() if it is writable.

if (!is_writable(session_save_path())) {
echo 'Session path "'.session_save_path().'" is not writable for PHP!';
}

PHP Session variable is not saving

Not sure what your 3rd page looks like but mine would be:

session_start(); // Use session variable on this page. This function must put on the top of page.

if( isset($_SESSION['i_am_in']) ) echo "logged in";

My Page 2:

if ($login_ok) {
session_start(); // Create session & settings
$_SESSION['abc123'] = 'whatever';
header('Location: page3.php');
}

$_SESSION not saving

I found the problem, the thing is it's a domain inside a domain inside a shared server, maybe that's why it had problems with $_SESSIONS, what I just did what host it in the root domain of that shared server. Now it does work.

PHP Session data not being saved

Thanks for all the helpful info. It turns out that my host changed servers and started using a different session save path other than /var/php_sessions which didn't exist anymore. A solution would have been to declare ini_set(' session.save_path','SOME WRITABLE PATH'); in all my script files but that would have been a pain. I talked with the host and they explicitly set the session path to a real path that did exist. Hope this helps anyone having session path troubles.



Related Topics



Leave a reply



Submit