文凯老师Thinkphp的Cookie怎么用?!
我用php的方法试了也不行,用Thinkphp自带的方法就一会可以,但是我一删除Runtime之后就再也不行了,怎么也登陆不了!
public function logn(){
$data=D('User');
$me['name']=$_POST['name'];
$me['password']=md5($_POST['password']);
if($data->where($me)->select()){
if($_SESSION['verify']!=md5($_POST['verify'])){
$this->error('验证码输入错误');
}
$uid=$data->where('id')->find();
Cookie::is_set('userId');
Cookie::set('userId',$uid);
Cookie::set('userId',$uid,60*60*24);
$this->assign("jumpUrl","/");
$this->success('登陆成功');
}else{
$this->error('用户名或密码错误');
}
}
上面是cookie的代码;
然后我在每个文件里面引入这段
<?php
if(!$_COOKIE["userId"]){
header("Location:/index.php/user/login");
}
?>
登陆后显示成功但是马上又跳转到index.php/user/login登陆!
public function logn(){
$data=D('User');
$me['name']=$_POST['name'];
$me['password']=md5($_POST['password']);
if($data->where($me)->select()){
if($_SESSION['verify']!=md5($_POST['verify'])){
$this->error('验证码输入错误');
}
$uid=$data->where('id')->find();
Cookie::is_set('userId');
Cookie::set('userId',$uid);
Cookie::set('userId',$uid,60*60*24);
$this->assign("jumpUrl","/");
$this->success('登陆成功');
}else{
$this->error('用户名或密码错误');
}
}
上面是cookie的代码;
然后我在每个文件里面引入这段
<?php
if(!$_COOKIE["userId"]){
header("Location:/index.php/user/login");
}
?>
登陆后显示成功但是马上又跳转到index.php/user/login登陆!
作者: hygzs 发布时间: 2011-07-10
Cookie::get("userId")
作者: 李明_ 发布时间: 2011-07-10