Question : PHP - session variables lost between subfolders

I have a file in that sets a few session variables as below:


$_SESSION['user'] = "OK";
$_SESSION['id'] = $row_user['id'];
$_SESSION['contact'] = $row_user['contact'];

and another file in the same directory that checks the session variable which displays the session data OK.

<?php session_start();
echo "session user".$_SESSION['user'];
echo $_SESSION['userid'];
echo $_SESSION['contact'];            

But if I then go to any files outside the subfolder say and then go back to session_variables are all lost.

I have session_start() on all files in my website so why am I losing session data?

Answer : PHP - session variables lost between subfolders

Rather than try to program around deprecated features of the language, it might be a better practice to use STRICT error reporting and fix the programming that relied on the deprecated features.  Testing the environment for dangerous conditions is one part of being a professional.  Here is one example of how to do that.

Best to all, ~Ray
if (ini_get('register_globals')) die('DANGER = register_globals is ON');
Random Solutions  
programming4us programming4us