How Sessions Are Supported 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.

Table of Contents

 About This Book

 Introduction and Installation of PHP

 PHP Script File Syntax

 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

 Arrays - Ordered Maps

 Interface with Operating System

 Introduction of Class and Object

 Integrating PHP with Apache Web Server

 Retrieving Information from HTTP Requests

Creating and Managing Sessions in PHP Scripts

 What Is a Session

How Sessions Are Supported in PHP

 SessionPage*.php - Session Test Script Pages

 Running Session Test Script Pages

 Managing Session IDs without Cookies

 Where Is Session Data Stored

 Sending and Receiving Cookies in PHP Scripts

 Controlling HTTP Response Header Lines in PHP Scripts

 Managing File Upload

 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

 Parsing and Managing HTML Documents

 Configuring and Sending Out Emails

 Image and Picture Processing

 Managing ZIP Archive Files

 Managing PHP Engine and Modules on macOS

 Managing PHP Engine and Modules on CentOS

 Archived Tutorials

 References

 Full Version in PDF/EPUB