PHP - Session Variables
SESSION variables, no matter what Server Model language you use, must first be declared (login) and destroyed at the end (logout). Assuming you have PHP 4.1 or higher.
Initialize Session - This must be at the top of every page that will call/use a Session variable.
Register (declare) a Session variable - To add a Session variable that will be carried till the browser is closed or you kill it yourself.
Assigning value to a Session variable - Values added to a Session variable can be letters (ABCabc), numbers (1, 200, 999.99, etc.) making them good for usernames/userID's when logged into a site.
Unregister a Session variable - Logging out requires we unregister any and all Session variables used for our application and the users' account.
Destroy a Session - We should always destroy a Session to help complete a logout.
Tutorial link - http://www.w3technology.info/2011/02/php-login-page-exampleusing-session.html
Initialize Session - This must be at the top of every page that will call/use a Session variable.
<?php session_start(); ?>
Register (declare) a Session variable - To add a Session variable that will be carried till the browser is closed or you kill it yourself.
<?php session_register("mySessionVariable"); ?>
Assigning value to a Session variable - Values added to a Session variable can be letters (ABCabc), numbers (1, 200, 999.99, etc.) making them good for usernames/userID's when logged into a site.
<?php $_SESSION["mySessionVariable"] = "MEMBER"; ?>
Unregister a Session variable - Logging out requires we unregister any and all Session variables used for our application and the users' account.
<?php session_unregister("mySessionVariable"); ?>
Destroy a Session - We should always destroy a Session to help complete a logout.
<?php session_destroy(); ?>
Tutorial link - http://www.w3technology.info/2011/02/php-login-page-exampleusing-session.html
No comments: