PHP Tutorials - Herong's Tutorial Examples - Version 4.18, by Dr. Herong Yang
How Sessions Are Support in PHP?
This section describes how sessions are supported in PHP. Session IDs are passed as cookies or GET/POST variables. session_start() is the built-in function to start a session. $_SESSION is the built-in array to manage session data.
PHP supports Web sessions with following main elements in the configuration file, php.ini:
1. session.use_cookies = 1/0 - A setting to determine if the session ID should be stored and managed as a cookie.
2. session.use_trans_sid = 1/0 - A setting in the configuration file, php.ini, to control if the session ID should be stored and managed transparently as a parameter in the URL.
3. session.save_handler = files/mm/user - A setting in the configuration file, php.ini, to control how session data should be stored.
4. session_start() - A built-in function to create a new session or resume an existing session. When session_start() is called, the PHP engine will check the current HTTP request to see if an existing session ID is included or not.
5. $_SESSION - A built-in array attached to the current session acting as a storage. You can store any number of key-value pairs in $_SESSION in a PHP script and retrieve them later in another script if it shares the same session as the first script.
6. session_name() - A built-in function to set and get the name of the current session.
7. session_id() - A built-in function to set and get the session ID of the current session.
8. session_destroy() - A built-in function to destroy the current session. When the current session is destroyed, information stored in $_SESSION will be removed.
Last update: 2015.
Table of Contents
Introduction and Installation of PHP 7.0
PHP Data Types and Data Literals
Variables, References, and Constants
Expressions, Operations and Type Conversions
Conditional Statements - "if" and "switch"
Loop Statements - "while", "for", and "do ... while"
Function Declaration, Arguments, and Return Values
Configuring and Sending out Emails
Retrieving Information from HTTP Requests
►Creating and Managing Sessions in PHP Scripts
►How Sessions Are Support in PHP?
SessionPage*.php - Session Test Script Pages
Running Session Test Script Pages
Managing Session IDs without Cookies
Sending and Receiving Cookies in PHP Scripts
Controlling HTTP Response Header Lines in PHP Scripts
MySQL Server Connection and Access Functions
Functions to Manage Directories, Files and Images
SOAP Extension Function and Calling Web Services
SOAP Server Functions and Examples
Localization Overview of Web Applications
Using Non-ASCII Characters in HTML Documents
Using Non-ASCII Characters as PHP Script String Literals
Receiving Non-ASCII Characters from Input Forms
"mbstring" Extension and Non-ASCII Encoding Management
Managing Non-ASCII Character Strings with MySQL Servers
Introduction of Class and Object