snippet library logo
Amazon.com
in category
PHP / Cookies / Sessions / Easy Session setup
Snippet details
ID: 104
Viewed: 2295
Added: 2004-06-10
Version: php4.1+
Sorry no demo

User Rated at:
Rate This:
Snippets in this catagory         
Show Printable Version
This script show you how to setup a session and read that session variable. if no session variable is found then it is passed to a form so they can start a session.

works on php version 4.1+

General Details
Snippet uploaded by: snippet
Email : webmaster@snippetlibrary.com
Snippet By: snippet

<!---Head--->
<?php
//must go at the beginning of the page.
session_start();
?>

<!---Body--->


<?php
//if you want to check for the variable that is 
//suppose to be in the session, one way is this.
//lets say $_POST['username'] is from the form.
if (isset($_POST['username'])){
//if it is set, you want to verify that it is the user
//I would run check on the Database to be sure.

//after you have checked it with the database and 
// all is ok, then you need to register the variables
// you got from the database
$_SESSION['userid'] = $variableFromDB
$_SESSION
['username'] = $variableFromDB

}else{
//goto form so they can login and to creat a session.

}
?>




No Reviews to show


Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Subject:

Reviewed By:

Write a review:





Terms of Conditions
Powered By
Avian Hosting
© 2005 snippetlibrary.com All Rights Reserved.