diff --git a/app/common/model/User.php b/app/common/model/User.php index f892999..8db188e 100644 --- a/app/common/model/User.php +++ b/app/common/model/User.php @@ -5,6 +5,7 @@ use think\Model; use think\model\concern\SoftDelete; use think\facade\Db; use think\facade\Session; +use think\facade\Cookie; use think\facade\Log; use taoler\com\Api; @@ -54,6 +55,11 @@ class User extends Model //将用户数据写入Session Session::set('user_id',$user['id']); Session::set('user_name',$user['name']); + if(!empty($data['remember'])){ + Cookie::set('user_id', $user['id'], 604800); + Cookie::set('user_name', $user['name'], 604800); + } + $ip = request()->ip(); /* $url = 'http://ip-api.com/json/'.$ip.'?lang=zh-CN'; diff --git a/app/index/controller/User.php b/app/index/controller/User.php index 7d8b8ad..5cc2c22 100644 --- a/app/index/controller/User.php +++ b/app/index/controller/User.php @@ -8,6 +8,7 @@ use think\facade\Db; use think\facade\Request; use think\facade\Session; use think\facade\Cache; +use think\facade\Cookie; use think\facade\View; use app\common\model\Article; use app\common\model\Collection; @@ -199,6 +200,8 @@ class User extends BaseController public function logout() { Session::clear(); + Cookie::delete('user_name'); + Cookie::delete('user_id'); if(Session::has('user_id')){ return json(['code' => -1, 'msg' => '退出失败']); } else { diff --git a/app/index/middleware.php b/app/index/middleware.php index 3cdfe4f..2918e68 100644 --- a/app/index/middleware.php +++ b/app/index/middleware.php @@ -1,6 +1,7 @@ captcha + +
+ + 忘记密码?