PHP的SESSION无效,怎么都写入不进去,在别的文件就用的很好的。

WBOY
Release: 2016-06-23 14:02:55
Original
1467 people have browsed it

帐号或密码错误!"; } }?>  后台管理页面 
username:
password:
Copy after login


代码如上,很简单,但是SESSION一直都写不进去,不知道到底是什么原因!!


回复讨论(解决方案)

$_SESSION['login_status'] ="oko"; //赋值是一个=号

你试一下把

修改后的代码

if(isset($_POST['sub'])){
require "./config.php";
if($_POST['login_name']==$admin_name && $_POST['login_pwd']==$admin_pwd){
$_SESSION['login_status']="oko";//这个地方你多了个“=”
}else{
echo "帐号或密码错误!";
}
}else{
session_start();//session_start();运行一次就可以了,而且要放在代码的最前边
}
?>


后台管理页面


if($_SESSION['login_status']!="oko"){
var_dump($_SESSION['login_status']);//这个地方一直是NULL
?>

username:

password:



}else{
echo "ll";
var_dump($_SESSION['login_status']);//要这个地方就可以打印了
}
?>



$_SESSION['login_status']="oko"; //赋值是一个=号

==号错了

好吧,我承认我SB了。。。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!