Session can we define as series of interaction between a single client and the web server, which take place over an extended period of time.
Important points of Session :
Session store information on server side. Storing a data on client machine and have to pass it back and forth between the server and client each time, it’s far more practical to keep the data on server, but give a client a ‘key’ to allow it to uniquely identify itself. A key is called a session identifier, it is uniquely associates a client with session. Session identifier also known as the SID (Session ID)
PHP creates its SID whenever we use session_start() or certain other session-related function like session_register(). SID kept in global variable named PHPSESSID.
When we start PHP session, the server assigns it a SID. and variable which we register as session variable are then stored on the server in a cookie-like file. The name of file generally the same as the value of the SID. OR SID would be part of URL
The length of session is determined by the session timeout setting in ‘php.ini’ file. The default is 1,440 seconds (24 min.)
Session is widely use for below mentioned things:
Session use when we want to work with sensitive information.
Session can support store data into $_SESSION super global variable.
If you turn on session.auto_start then the only way to put objects into your sessions is to load its class definition using auto_prepend_file in which you load the class definition else you will have to serialize() your object and unserialize() it afterwards.
Sessions that a record of a session is not created until a variable has been registered using the session_register() function or by adding a new key to the $_SESSION superglobal array.
Session Constant:
* SID
* PHP_SESSION_DISABLED (5.4 Only)
* PHP_SESSION_NONE (5.4 Only)
* PHP_SESSION_ACTIVE (5.4 Only)