Question : PHP - session variables lost between subfolders

I have a file in www.mywebsite.com/subfolder/test.php that sets a few session variables as below:

session_start();

$_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.
www.mywebsite.com/subfolder/test2.php

<?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 www.mywebsite.com/index.php and then go back to www.mywebsite.com/subfolder/test2.php 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
1:
if (ini_get('register_globals')) die('DANGER = register_globals is ON');
Random Solutions  
 
programming4us programming4us