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
Is MySQLi_Multi_Query Asynchronous
Explode a Paragraph into Sentences in PHP
Select MySQL Rows But Rows into Columns and Column into Rows
Pdo: Call to a Member Function Fetch() on a Non-Object
Converting a Postman Request to Curl
What Does Header('P3P: Cp="Cao Psa Our"'); Do
How to Document Magic (_Call and _Callstatic) Methods for Ides
PHP Session with an Incomplete Object
How to Use Perl Libraries from PHP
Using Windows Authentication with PHP
Azure Active Directory Sso with Laravel
Get Content Within a HTML Tag Using PHP and Replace It After Processing
Simple Xml Add Namespaced Child
How to Visualize a Bunch of Functions in Uml