I am some what new to PHP and this is my first time using sessions. I am working on a page that links to itself but displays different content depending on what was selected from the menu. I have a login in prompt that "POSTS" a user name, I want this user name to remain but it disappears. After I submit the user name it reloads the page and the user name can be displayed, but if I select another menu item and the page reloads, the user name is gone. I am able to read the session data in the directory it's being written to so I think it is kinda working. But everytime the page reloads a new sesssion is created, is this suppose to happen? I thought when you used "session_start();" it looked for a current session first. Anyways, any thoughts or ideas would be much appreciated, here is some of my code.
<?php
session_start();
if($GET['var']=="login") {
$SESSION['userName']=$POST['userName'];
$SESSION['userPass']=$POST['userPass'];
$SESSION['authUser']=0;
if(($SESSION['userName']=="chris") &&
$SESSION['userPass']=="password")) {
$_SESSION['authUser']=1;
}
}
?>
...and then when i recall the session data...
if(isset($SESSION['authUser']) && $SESSION['authUser']==1) {
echo "Hello $_SESSION[userName]";
}