我做了一个简单的会话,并在我的localhost(xampp)上完美地工作
第一页是这样的
<?php
if(!session_start()):
session_start();
endif;
?>
<?php
$_SESSION['user'] = "grace1004";
echo '<a href = "2ndpage.php">Please Click</a>';
?>
第二页
<?php
if(!session_start()):
session_start();
endif;
?>
<?php
if($_SESSION['user']) {
echo $_SESSION['user'];
}
else {
echo ' hahahaha'; //i made this to check if the session is being stored
}
?>
即时使用000webhostapp,错误显示未定义索引:用户
答案 0 :(得分:0)
<?php
session_start();
if(!empty($_SESSION['user'])) {
echo $_SESSION['user'];
}
else {
echo ' hahahaha'; //i made this to check if the session is being stored
}
?>