php cookie 在其他页面读取不了
<?phpsession_start();include_once("../conn/conn.php");include_once("../pub/fun_file.p...
<?php session_start();
include_once("../conn/conn.php");
include_once("../pub/fun_file.php");
$email=trim($_POST["uemail"]);
$psword=trim($_POST["psword"]);
$keepLogin=$_POST["chk"];
$info=$conn->execute("select email,nickname,id from tb_user where email='".$email."' and psword='".$psword."'");
if($info!=false){
$_SESSION["nme"]=$info->fields['nickname'];
$_SESSION["ud"]=$info->fields[id];
if(!empty($keepLogin)){
setcookie("TestCookie","123", time()+3600*24);
echo $_COOKIE['TestCookie'];
}
$json_arg=array('ishave'=>true,'nickname'=>$info->fields[nickname],'email'=>$email);
$json_result= json_encode(gbk2utf8($json_arg));
echo $json_result;
exit;
}else{
$json_arg=array('ishave'=>false);
$json_result= json_encode(gbk2utf8($json_arg));
echo $json_result;
exit;
}
明明已经成功设置cookie了,但是在其他页面无法读取,求解,谢谢 展开
include_once("../conn/conn.php");
include_once("../pub/fun_file.php");
$email=trim($_POST["uemail"]);
$psword=trim($_POST["psword"]);
$keepLogin=$_POST["chk"];
$info=$conn->execute("select email,nickname,id from tb_user where email='".$email."' and psword='".$psword."'");
if($info!=false){
$_SESSION["nme"]=$info->fields['nickname'];
$_SESSION["ud"]=$info->fields[id];
if(!empty($keepLogin)){
setcookie("TestCookie","123", time()+3600*24);
echo $_COOKIE['TestCookie'];
}
$json_arg=array('ishave'=>true,'nickname'=>$info->fields[nickname],'email'=>$email);
$json_result= json_encode(gbk2utf8($json_arg));
echo $json_result;
exit;
}else{
$json_arg=array('ishave'=>false);
$json_result= json_encode(gbk2utf8($json_arg));
echo $json_result;
exit;
}
明明已经成功设置cookie了,但是在其他页面无法读取,求解,谢谢 展开
展开全部
给cookie设置作用域
setcookie("TestCookie","123", time()+3600*24,'/');试试加个参数
setcookie("TestCookie","123", time()+3600*24,'/');试试加个参数
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
那是不是在其他页面没有session_start();这句
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询