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. If session Autostart
is not configured in php.ini, you must manually open session: 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:
<?php session_start(); echo $_SESSION['username']; ?>
If you want to know more about programming learning, please pay attention to the php training column!
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!