On my site, if you display the value of a variable in a session, for example:

echo $_SESSION["key]; 

then it sees everything from the script index.php , and if it accesses the same variable from another script, it is located in the nested directory, then it displays an empty value. What is the reason? Or I did not quite understand the scope of the sessions.

 /*index.php*/ ... echo $_SESSION["key"];// 1234567890 


 /*mydir/msg.php*/ echo $_SESSION["key"];// пусто!!! 

    2 answers 2

    $_SESSION is a superglobal variable. To access it, you need to call session_start ();

    • yes there was no start of sessions ... - Yoharny Babay

    Function session_start (); present in both scripts?