預設常數

以下常數由擴充功能定義,因此只有在擴充功能被編譯到 PHP 中,或者在執行時被動態載入後才有效。

SID (string)
Constant containing either the session name and session ID in the form of "name=ID" or empty string if session ID was set in an appropriate session cookie. This is the same id as the one returned by session_id().
PHP_SESSION_DISABLED (int)
Since PHP 5.4.0. Return value of session_status() if sessions are disabled.
PHP_SESSION_NONE (int)
Since PHP 5.4.0. Return value of session_status() if sessions are enabled, but no session exists.
PHP_SESSION_ACTIVE (int)
Since PHP 5.4.0. Return value of session_status() if sessions are enabled, and a session exists.
add a note add a note

User Contributed Notes 2 notes

up
13
sarath dot jasrin at gmail dot com
7 years ago
Check whether session started using Predefined Constants

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
up
10
Anonymous
7 years ago
SID constant defined dynamically!

var_dump(defined('SID'));  // bool(false) - Not defined...
session_start();
var_dump(defined('SID'));  // bool(true) - Defined now!
To Top