PHP Sessions

In this tutorial you will learn about the PHP Sessions and its application with practical example.

PHP Sessions are information passing mechanism that allows to make data accessible across the various pages of an entire website using the super global array.PHP session allows us to keep track of visitor across website.The main difference between a cookie and a session is that a cookie is stored on client’s computer while session variables stores on the server.

Before using session you need to start the session and as the session starts it creats unique id (UID) for each visitor and store variables based on this UID this ID can be accessed using “PHPSESSID”.

Starting a PHP Session

Note: The session_start() function must appear BEFORE the <html> tag

Define Session Variable

Reading Session Variable

Destroying a Session

 

In this tutorial we have learn about the PHP Sessions and its application with practical example. I hope you will like this tutorial.