public function dologin(Request $request)
{
$data = $request->post();
$user = Db::table(self::$db)->where('tel',$data['name'])->find();
if (empty($user)) {
return json([
'code'=>0,
'msg'=>'请注册',
'url'=>url('/index/login/login')]);
}
if(md5($data['pwd']) == $user['pwd']){
session('name',$user['name']);
session('tel',$user['tel']);
session('id',$user['id']);
return json([
'code'=>1,
'msg'=>'登录成功',
'url'=>url('/index/index/index')
]);
}else{
return json(['code'=>0,'msg'=>'密码错误']);
}
}
// 在本控制器我取
public function sess()
{
echo session('name');
echo session('tel');
echo session('id');
echo '111';
}
取不到 。只有111
config这
return [
'id' => '',
// SESSION_ID的提交变量,解决flash上传跨域
'var_session_id' => '',
// SESSION 前缀
'prefix' => 'think',
// 驱动方式 支持redis memcache memcached
'type' => '',
// 是否自动开启 SESSION
'auto_start' => true,
];
最佳答案