Top 3 Products & Services


Dated: Sep. 19, 2005

Related Categories

PHP Programming

By Najmi

Building web applications with membership management is one of the most frequent tasks that every programmer does. Managing membership data, such as username, password and the member's profile with sessions in PHP is the easiest and simplest solution.

Sessions stores data about a particular user that you need on all of the pages in a variable and access it from any page. Using sessions you could hold data about particular user and access that info on all the pages as long as the user is active on the site.

PHP Sessions Each session holds different values for different user. Sessions automatically die when the user's session is over or he closes his browser.

PHP's session-handling features, was first introduced in the 4.0 release. Sessions are native and thus require no additional packages.

To work with Sessions we will be using session_start() and session_register() functions, its important that you add sesions_start to every page where you would like to use sessions.


// create a new session

// register a session-variable
session_register("color"); //we have created a session with name color

$color = "blue"; //assigning some value to our session

Okay now we have created a session with name color and assigned it as blue, now in our second program (session2.php) we access the value of our session color.



echo "The value stored in your session: " $color; //retriving value from the session

To delete a session variable we use the function session_unregister() so to delete our session color we would use the code.


That's It!
The End!

Now that you've gotten free know-how on this topic, try to grow your skills even faster with online video training. Then finally, put these skills to the test and make a name for yourself by offering these skills to others by becoming a freelancer. There are literally 2000+ new projects that are posted every single freakin' day, no lie!

Previous Article

Next Article