In my index.php file I call session_start()
and set a couple of session variables. In a second PHP file I would like to access these session variables.
session_start();
is the answer of most of topic like this. i have been struggling with this issue and i solve my problem with this code
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
if(session_id() == '') {session_start();}
} else {
if (session_status() == PHP_SESSION_NONE) {session_start();}
}
I had this problem and tried different ways and finally found a solution :
PHP is case sensitive, Use $_SESSION instead of $_session in all php files.certainly It works . Example :
<?php
session_save_path('tmp/'); (is not optional - it is mandatory)
session_start();
echo $_SESSION["s1"]."<br/>";
echo $_SESSION["s2"]."<br/>";
?>