session_start
Start a new session or resume an existing session
Function name: session_start()
Applicable version: PHP 4, PHP 5, PHP 7
Usage: The session_start() function is used to start a new session or restore the current session. This function must be called before using a session variable.
Example:
// 开始一个新的会话session_start(); // 设置会话变量$_SESSION['username'] = 'John'; // 输出会话变量echo "用户名:" . $_SESSION['username'];
In the above example, we first call the session_start() function to start a new session. Then, we use the $_SESSION hyperglobal array to set the value of a session variable $_SESSION['username']
to 'John'. Finally, we output the value of the session variable through echo
statement.
Notes: