Cml\Http\Cookie::get PHP Метод

get() публичный статический Метод

获取某个Cookie值
public static get ( string $name ) : boolean | mixed
$name string 要获取的cookie名称
Результат boolean | mixed
    public static function get($name)
    {
        if (!self::isExist($name)) {
            return false;
        }
        $value = $_COOKIE[Config::get('cookie_prefix') . $name];
        return Encry::decrypt($value);
    }

Usage Example

Пример #1
0
 /**
  * 校验验证码
  *
  * @param bool $isCn 是否为中文验证码
  * @param string $input 用户输入
  * @param string $verifyName 生成验证码时的字段
  *
  * @return bool 正确返回true,错误返回false
  */
 public static function checkCode($input, $isCn = false, $verifyName = 'verifyCode')
 {
     $key = \Cml\Http\Cookie::get($verifyName);
     if (!$key) {
         return false;
     }
     $code = \Cml\Model::getInstance()->cache()->get($key);
     \Cml\Model::getInstance()->cache()->delete($key);
     $isCn && ($input = md5(urldecode($input)));
     if ($code === false || $code != $input) {
         return false;
     } else {
         return true;
     }
 }
All Usage Examples Of Cml\Http\Cookie::get