session_reset
Reinitialize the session array with the original value
Function name: session_reset()
Applicable version: PHP 5 >= 5.6.0, PHP 7
Function Description: The session_reset() function will reinitialize all session variables and move the session pointer to the beginning of the session array.
Syntax: session_reset()
Example:
// 开启会话session_start(); // 设置会话变量$_SESSION['username'] = 'John'; $_SESSION['age'] = 25; // 输出会话变量echo $_SESSION['username']; // 输出:John echo $_SESSION['age']; // 输出:25 // 重置会话变量session_reset(); // 输出会话变量echo $_SESSION['username']; // 输出:John echo $_SESSION['age']; // 输出:25
illustrate:
session_start()
function to start the session.$_SESSION
hyperglobal variable to set the session variable.session_reset()
function moves the session pointer to the beginning of the session array and reinitializes the session variable.session_reset()
, the session variable is still accessible.session_reset()
function will only reset the current session and will not affect other sessions.session_reset()
function will throw a warning.Additional Notes:
session_unset()
function.session_destroy()
function.