I've went through various threads about this problem and couldn't find a solution.
I'm using the following code:
<?php
session_start();
ini_set('display_errors', 'on');
error_reporting(-1);
session_name("hello");
$_SESSION['username'] = "name";
echo $_SESSION['username'];
echo session_id();
if (is_writable(session_save_path()))
{
echo "writable";
}
?>
This is the output:
name771e6d83a8578e2dbadac64dc62b5788writable
Yet the session ID output keeps changing on every page refresh.
It is happening in all browsers I tried (Chrome, IE, FF).
In none of the browsers I couldn't locate a PHPSESSID
cookie that is supposed to be sent from my domain.
Since the output yields writable
, this shouldn't be a permission problem.
These are my php.ini
settings:
session_auto_start
is set to 0
, like I guess it should be.
What can be causing this problem?
I'm trying to learn sessions, started with this simple code and can't get over this issue.
Another note:
As you can see, I've set error reporting, and I don't get any special errors when I test this code on my VPS server.
However, when I run the same code on some shared hosting account that I have on another server, I'm getting a headers already sent on line 2
error. I don't what exactly is making the difference, but I intend to run my project only on my VPS server anyway.