I have a very simple code that works fine under a Strato server but when running in my own Apache2 server the code doesn't works.
I have one file called "checklogin.php" with this code
<?php
session_start();
$_SESSION['username'] = 'alex';
echo "Bienvenido! " . $_SESSION['username'];
echo "<br><br><a href=panel-control.php>Panel de Control</a>";
?>
And second file called "panel-control.php" with this code:
<?php
session_start();
$username = $_SESSION['username'];
echo "Hola $username";
?>
The problem is that I can't get the _SESSION data because the server starts a new session every time I call the session_start()
When I see at the server side the sessions folder is ok and I can see the files of every session "sess_...." with the data "username|s:4:"alex";" this means the folder is writable and the php is sending the data ok, but, when the second page is loaded a new session is created and can see an error in the Apache2 log file telling the undefined index because the session is new and _SESSION not contains the variable "username", obvious bacause is a new session without data.
Well, I spent some hours with this and can't see the problem. I tried runing Apache2 with php5.6 and 7.0 with the same results and the php.ini file is well configured (same configuration as the file in the Strato server where the code runs ok).
Any ideas?
Thanks for reading.