Home>Article>Backend Development> What should I do if php SESSION cannot be passed across pages?
Methods to solve the problem that php SESSION cannot be passed across pages: 1. [session_start();] should be placed at the top of the page as much as possible; 2. [session: session_start();] must be manually turned on.
Methods to solve the problem that php SESSION cannot be passed across pages:
1,session_start();
It should be placed at the top of the page as much as possible;
2. Ifsession Autostart
is not configured in php.ini, you must manually opensession: session_start before each session. ();
3. Session is a super global variable in PHP, just like $_GET, $_POST, $_SERVER, so it must be capitalized when used:
$_SESSION['username']=$username;
4. Cross-page transfer example: a.php page transfers$_SESSION['username']
to b.php:
a.php:
b.php:
If you want to know more about programming learning, please pay attention to thephp trainingcolumn!
The above is the detailed content of What should I do if php SESSION cannot be passed across pages?. For more information, please follow other related articles on the PHP Chinese website!