So I create a session on one page and create a new variable called uName and assign a value. I go to another page and try to echo the value but I get an error:\"Undefined variab
You need to call session_start() again at beginning of the new file, like so:
<?php
session_start();
echo "My Name is " . $_SESSION['uName'];
page1.php
<?php
session_start();
$_SESSION['uName'] = "Mike";
?>
page2.php
<?php
session_start();
echo "My Name is " . $_SESSION['uName'];
//eventually
unset($_SESSION['uName']);
?>
You need to add session_start(); to all files that use sessions.