Session::set('user_id',$user->id);
Session::set('user_info',$user->getData());
人生如戏2018-05-05 17:13:10
user.php
....
use think\Request;
use app\index\model\User as UserModel;
# use think\Session;
....
public function checkLogin(Request $request)
{
//初始回傳參數
# $status = 0;
$result = '';
$data = $request ->;
## $rule = [ 'name|使用者名稱' =>'require', 關鍵字## 'veritfy|驗證碼' =>'require|captcha', ];# $msg = [
'name' =>['require'=>'使用者名稱不能為空,請檢查'],#>#n; 'require'=>'密碼不能為空,請檢查'],
//簡單驗證
$result = $this -> validate($data,$rule,$msg);
//如果驗證成功,則執行# if ($result === true) { //建構查詢條件## $map ['name'],
'password'=>md5($data['password'])
## ];
#
$user = UserModel::get($map); if($user == null){ == null){ 找到該使用者! '; }else{# $status = 1;# $status = 1;
# $result = '
#//設定使用者的Session值
//Session::set('user_id',$user-> :: ('user_info',$user->getData());//取得使用者所有資訊
## Session::set('user_id,$user[id] ');