コード例 #1
0
ファイル: logout.php プロジェクト: universsky/lazybug-for-api
 public function act()
 {
     // 注销页面
     Util_Client_Cookie::unset_cookie('userid');
     Util_Server_Response::set_header_location('/login');
     exit;
 }
コード例 #2
0
ファイル: base.php プロジェクト: universsky/lazybug-for-api
 protected function unset_cookie()
 {
     Util_Client_Cookie::unset_cookie('userid');
     Util_Client_Cookie::unset_cookie('username');
     Util_Client_Cookie::unset_cookie('time');
     Util_Client_Cookie::unset_cookie('secstr');
 }
コード例 #3
0
ファイル: login.php プロジェクト: universsky/lazybug-for-api
 public function act()
 {
     // 登录流程
     if (!$this->check_param('username, password, issave')) {
         V('Json.Base')->init(Const_Code::LOGIN_PARAM_ERROR, '登录传递参数错误');
         return;
     }
     $username = trim(Util_Server_Request::get_param('username', 'post'));
     $password = trim(Util_Server_Request::get_param('password', 'post'));
     $is_save = (int) Util_Server_Request::get_param('issave', 'post');
     $time = time();
     $seckey = lb_read_system('seckey');
     $user_id = (int) M('User')->check_password($username, md5($username . $password));
     if (!$user_id) {
         V('Json.Base')->init(Const_Code::LOGIN_FAIL, '帐号验证失败');
         return;
     }
     $user = M('User')->get_by_id($user_id);
     $expire_time = $is_save ? 86400 * 30 : 0;
     Util_Client_Cookie::set_cookie('userid', $user_id, $expire_time);
     Util_Client_Cookie::set_cookie('username', $user['name'], $expire_time);
     Util_Client_Cookie::set_cookie('userrole', $user['role'], $expire_time);
     Util_Client_Cookie::set_cookie('time', $time, $expire_time);
     Util_Client_Cookie::set_cookie('secstr', md5($user_id . '$' . $user['name'] . '$' . $user['role'] . '$' . $time . '$' . $seckey), $expire_time);
     V('Json.Base')->init(Const_Code::SUCCESS, '帐号验证通过');
 }
コード例 #4
0
ファイル: base.php プロジェクト: universsky/lazybug-for-api
 public function get_cookie($file = '')
 {
     $saved_file = Util_Server_Request::get_cookie('cookiefile');
     if ($saved_file) {
         $file = $saved_file;
     } else {
         $file = $file ? $file : 'local-' . microtime();
         Util_Client_Cookie::set_cookie('cookiefile', $file, time() + 90 * 24 * 3600);
     }
     return APP_PATH . '/tmp/cookie/' . $file;
 }