Search code examples
phpsessionwebserverserver-configuration

session is always empty outside of the file where is generated


Why I am getting an empty array of the session when I am trying a var_dump in another page? In the server, the session is stored without any content, only with the name of the id. With cookies all works well. Sometimes (yes, sometimes), I restart the server, and then, the sessions works well too. What may cause this issue?

Maybe a bug of the php 5.1.6? or a problem in the config of the server?

index_2.php

<?php
session_start();
$_SESSION['xxx'] = "tessstsse";
var_dump($_SESSION);//here show the correct session
header( 'Location: index_3.php');

index_3.php

<?php
session_start();
var_dump($_SESSION);

The output of this will be:

array
  empty

Solution

  • I have the web server without space to store the session content.

    0% of free space. Delete some data and the problem is solved.