SESSION variables cheat-sheet (PHP)
Need to know, or get a handle on SESSION variables in your dynamic sites for your PHP?
This is a refrence "cheat sheet," not a tutorial , so I provide tutorial links at the end.
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.
<?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"); ?>
We should always destroy a Session to help complete a logout.Destroy a Session
<?php session_destroy(); ?>
DMXzone Tutorials & Articles to learn more
Comments
Comments please
help
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at c:\program files\apache group\apache\htdocs\vhoreg\vho\vhohome.php:1) in c:\program files\apache group\apache\htdocs\vhoreg\vho\vhohome.php on line 1
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at c:\program files\apache group\apache\htdocs\vhoreg\vho\vhohome.php:1) in c:\program files\apache group\apache\htdocs\vhoreg\vho\vhohome.php on line 1
" wad does it mean????
You must me logged in to write a comment.