What is a Session in PHP?

Posted on Updated on

A PHP session is no different from a normal session. It can be used to store information on the server for future use. However this storage is temporary and is flushed out when the site is closed. Sessions can start by first creating a session id (unique) for each user.

A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests.

There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.

Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.

Syntax : session_start()
E.g. storing a customer’s information. 

A PHP session starts using:

<?php session_start(); ?>

A PHP session variable is used to hold values of the current session. A session needs to be started first.

// store session data

They can be used to hold information about a single user that is applicable to all web pages


2 thoughts on “What is a Session in PHP?

    Naresh Sharma said:
    April 7, 2013 at 11:02 am

    it is too good dude……….

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s