What Is a Session?
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.
How To Turn On the Session Support?
The session support can be turned on automatically at the site level, or manually in each PHP page script:
Turning on session support automatically at the site level: Set session.auto_start = 1 in php.ini.
Turning on session support manually in each page script: Call session_start() funtion
How To Save Values to the Current Session?
When session is turned on, a session will be automatically created for you by the PHP engine. If you want to save any values to the session, you can use the pre-defined associative array called $_SESSION. The following PHP script shows you how to save values to the session: