Example #1
0
 /**
  * 获取当前用户
  * @method getUser
  * @return [type]  [description]
  * @author NewFuture
  */
 public static function getUser()
 {
     if ($user = Session::get('user')) {
         /*session中的信息*/
         return $user;
     } elseif (($token = Cookie::get('token')) || Input::I('SERVER.HTTP_TOKEN', $token)) {
         /*解析cookie*/
         if ($token = Encrypt::aesDecode($token, Cookie::key(), true)) {
             list($uid, $token, $time) = explode(':', $token);
             if ($time + Config::get('cookie.expire') > $_SERVER['REQUEST_TIME'] && ($user = self::checkToken($uid, $token))) {
                 /*token有效*/
                 Session::set('user', $user);
                 return $user;
             }
         }
     }
 }
Example #2
0
File: Cookie.php Project: wuxw/YYF
 /**
  * 获取cookie
  * @method get
  * @param  [string] $name [cookie名称]
  * @return [json]
  * @author NewFuture
  */
 public static function get($name)
 {
     if (isset($_COOKIE[$name]) && ($data = Encrypt::aesDecode($_COOKIE[$name], self::config('key'), true))) {
         return @json_decode($data);
     }
 }
Example #3
0
 /**
  * Cookie数据解密
  * @method encode
  * @param  [type] $data         [description]
  * @return [type] [description]
  * @author NewFuture
  */
 private static function decode($data)
 {
     if ($data = Encrypt::aesDecode($data, self::config('key'), true)) {
         return @json_decode($data);
     }
 }