This is my code:
INDEX.PHP
// index.php session_start(); $_SESSION['favcolor'] = 'red'; $_SESSION['animal'] = 'dog'; $_SESSION['time'] = time(); print_r($_SESSION);
The result is:
Array ( [favcolor] => red [animal] => dog [time] => 1439307117 )
After visiting the home, I go to the test page:
TEST.PHP
// test.php session_start(); echo $_SESSION['favcolor']; echo $_SESSION['animal']; echo date('Y m d H:i:s', $_SESSION['time']); print_r($_SESSION);
The result is:
Array ()
Why?
I solved the problem. I had the folder "var/lib/php/session" without write permissions.
Setting permissions with the command "chmod -R 777 /var/lib/php/session" everything is back to work.
Thanks to all for the tips.