Pages

Thursday 21 June 2012

PHP SESSIONS


In This Post We Will Discuss PHP SESSIONS Briefly.This is most commonly used in websites where user input or registeration is required most common example we see is in our mailing websites like ymail,gmail or banking sites like ebanking.we can say seesions are everywhere.
Moreover sessions are time slots of access.
Mechanism is like user1=time1 similarly user2=time2.When we signout from any site and after that no other person could access your id without password.
A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application.

PHP Session Variables

When we are working with an application, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you start the application and when you end. But on the internet there is one problem: the web server does not know who you are and what you do because the HTTP address doesn't maintain state.
A PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping items, etc). However, session information is temporary and will be deleted after the user has left the website. If you need a permanent storage you may want to store the data in a database.

Sessions work by creating a unique id (UID) for each visitor and store variables based on this UID. The UID is either stored in a cookie or is propagated in the URL.
An alternative way to make data accessible across the various pages of an entire website is to use a PHP Session.
A session creates a file in a temporary directory on the server where registered session variables and their values are stored. This data will be available to all pages on the site during that visit.
The location of the temporary file is determined by a setting in the php.ini file calledsession.save_path. Bore using any session variable make sure you have setup this path.




No comments:

Post a Comment