One of the great feature that php provides is sessions in php. This feature of php provides facility to store user data without using the cookies. All Social sites like Facebook and twitter uses this feature to manage the accounts of their users. This has really simplified the account management for all php users and have helped a lot in improving interface for the users.
What is a php session ?
PHP session is a way to store the data in variables that can be used on multiple pages. A php session is valid for a particular time period, for example, when you login to your Facebook account, your session starts and it is valid till you logout. As in sessions the information is stored in variables and that information is stored for a temporary time period that we call php session. Now a days most of the websites uses php sessions in their login system and these sessions make it easy to handle and manage users.
Simply we can say sessions in php stores the user data for a time period or valid sessions that can be used on different pages. For example, when you login to a website by entering your username and password then you are provided with a session by the host website and now you can access multiple pages without entering your username and passwords again and again, as your username and password are stored temporarily in some variables that are used on different pages and prevent you from entering your username and password each time you browse a new page.
How to create session in php
Coming to our main part that is creating a session in php, there is a complete process which you will read here and that is complete part about php sessions from starting a session to destroying it. The 4 parts are included in creating a session these are Starting a Session, getting the variable values, modifying the session variables and Destroying a session.
Start a PHP Session
A php session is started with session_start() function and the session variables are declared with the php global variable that is $_SESSION.
Now, we will create a page "session.php" in which we will start a new session and will declare some variables to store data.
Now, we will create a page "session.php" in which we will start a new session and will declare some variables to store data.
Getting php session variable values
Now we will create another page "session2.php" in which we will access the session information from our previous page that was "session.php"
Modifying php session variables
In order to change the previous session values we can simply modify them.
Destroying a php session
To remove all global session variables and destroy the session, use session_unset() and session_destroy():
It is all about sessions in php if you want to ask something or want to share about sessions in php you can comment below.

ConversionConversion EmoticonEmoticon