Detailed explanation of the usage of session_register function in PHP

Syntax: boolean session_register(string name);
Register new variables.
Return Value: Boolean
Function Type: Data Processing
Content Description
This function adds a variable in the global variable to the current Session. The parameter name is the name of the variable to be added. Returns a true value on success.
If you open the session in the header file, that is, use session_start() function followed by session_register(string name) (such as session_register('username')), then this variable becomes a global variable, which will affect all users who use session_start() document.
 Such as:

<?PHP
 session_start();
 $username = ‘test’;
 session_register(‘username’);
 echo $_session['username'];     //输出test
?>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325636657&siteId=291194637