在任何
PHP网页的最开头使用“
session_start()”函数,就在第一个PHP开始标记(
session_start(); // This line must be at the very beginning of this PHP page.
function one() {
// blah, blah, ...
if(isset($variable) && !empty($variable)) {
$_SESSION['customVariable'] = $variable;
}
// some more blah, blah, ...
}
?>
现在,如果你来到“second.php”页面,你需要访问这个页面的功能: –
function two() {
// if any blah, blah, ...
if(isset($_SESSION['customVariable']) && !empty($_SESSION['customVariable'])) {
$variable = $_SESSION['customVariable'];
}
// next series of blah, blah, ...
}
?>
但是在这个“second.php”页面中,必须在第一个PHP开始标记之后的本页开头写入“session_start()”函数.
希望能帮助到你.