Understanding PHP Sessions
A session is the time that a user spends at your Web site. Users might view many Web pages between the time they enter your site and leave it. Often
you want information to be available for a complete session. Beginning with version 4.0, PHP provides a way to do this.
 

Understanding how PHP sessions work

PHP allows you to set up a session and store session variables. You can then open a session on any other Web page and the session variables are
available for your use 
 
PHP will handle sessions in the following ways .
 
1) When user browser'  cookies are set to on
 
2) When user browse'r cookies are  set to off 
 
a). When trans-sid is turned on in PHP.ini (on webserver)
b). When trans-side is turned off in PHP.ini ( on webserver) 
 
1)When Browser cookies are on  
 
When cookies are enabled , PHP handles session in the following ways .
 
1. PHP assigns a session ID number.The number is a really long nonsense number that is unique for the user and that no one could possibly guess. The session ID is stored in a PHP system variable named PHPSESSID.
 
2. PHP stores the variables that you want saved for the session in a file on the server. The file is named with the session ID number. It’s stored in a directory specified by session.save_path in the php.ini file. The session directory must exist before session files can be saved in it.
 
3. PHP passes the Session ID in Cookies.
 
4. PHP gets the variables from the session file for each new session page.Whenever a user opens a new page that’s part of the session, PHP gets the variables from the file, using the session ID number that was passed from the previous page. The variables are available in the $_SESSION array.
 
2)When Browser Cookies are off 
 
  a). When trans-sid is turned on in PHP.ini (on webserver)
 
      PHP will automatically pass the value of session id as a hidden form field to the site .
 
GET:
If the user moves to the next page by using a link, a header function, or a form with the GET method, the session ID number is added to the URL 
POST: 
If the user moves to the next page by using a form with the POST method, the session ID number is passed in a hidden field. PHP recognizes PHPSESSID as the session ID number and handles the session without any special programming on your part.