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
Chris, Los Angeles' CSS & ActionScript guru, successfully cannonballed into web development in the late 90's. Always caught up with the latest in Flash, Dreamweaver, Fireworks, and XML, Chris authored premium articles for the largest Dreamweaver/Flash community (www.DMXzone.com) and produced WebDevDesign (iTunes featured), a popular Web Design & Development Podcast. Somewhere, Chris finds time to run an authorized Adobe user group focused around open source and Adobe technologies. Being a big community leader, Chris Charlton remains a resident faculty member of the Rich Media Insitute and lends himself to speak at large industry events, like JobStock, NAB, and FITC Hollywood.



Comments
Wilson Wang
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????
Chris Charlton
Comments please