session_start() question
| From: | C.R. | Date: | Thu, 08 May 2003 13:42:56 +0000 |
| Subject: | session_start() question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-146669@lists.php.net to get a copy of this message | ||
Can someone explain session_start() as I am still don't have a full grasp of
sessions. In the following example I have to use session_start() on both of
the pages below, but once a session is started why would I need to do this -
does it not carry from page to page? - confused.
page-a.php example:
session_start(};
if($_SESSION['loggedin']) { echo "You are already logged in"; }
else {
*** the login form appears here ***
<FORM NAME="Login" ACTION="page-b.php" METHOD="post">
.....etc....
}
page-b.php example;
*** code to validate input ***
if input is correct....
session_start();
$_SESSION['loggedin'] = "True";
$_SESSION['email'] = $row['email'];
$_SESSION['names'] = $row['firstname']."
".$row['lastname'];