当前位置: 首页>>代码示例>>PHP>>正文


PHP WebRequest::getCookie方法代码示例

本文整理汇总了PHP中WebRequest::getCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP WebRequest::getCookie方法的具体用法?PHP WebRequest::getCookie怎么用?PHP WebRequest::getCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebRequest的用法示例。


在下文中一共展示了WebRequest::getCookie方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAccessToken

 /**
  * Extracts access token from HTTP request data.
  *
  * @param \WebRequest $request the HTTP request data as an object
  * @return String access token or null
  */
 public static function getAccessToken(\WebRequest $request)
 {
     // A cookie takes precedence over an HTTP header.
     $token = $request->getCookie(self::ACCESS_TOKEN_COOKIE_NAME, '');
     // No access token in the cookie, try the HTTP header.
     if (!$token) {
         $header = $request->getHeader('AUTHORIZATION');
         $matches = [];
         preg_match('/^Bearer\\s*(\\S*)$/', $header, $matches);
         if (!empty($matches[1])) {
             $token = $matches[1];
         }
     }
     // Normalize the value so the method returns a non-empty string or null.
     if (empty($token)) {
         return null;
     }
     return $token;
 }
开发者ID:yusufchang,项目名称:app,代码行数:25,代码来源:User.class.php

示例2: getCookie

 /**
  * Get a cookie. Contains an auth-specific hack.
  * @param \WebRequest $request
  * @param string $key
  * @param string $prefix
  * @param mixed $default
  * @return mixed
  */
 protected function getCookie($request, $key, $prefix, $default = null)
 {
     $value = $request->getCookie($key, $prefix, $default);
     if ($value === 'deleted') {
         // PHP uses this value when deleting cookies. A legitimate cookie will never have
         // this value (usernames start with uppercase, token is longer, other auth cookies
         // are booleans or integers). Seeing this means that in a previous request we told the
         // client to delete the cookie, but it has poor cookie handling. Pretend the cookie is
         // not there to avoid invalidating the session.
         return null;
     }
     return $value;
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:21,代码来源:CookieSessionProvider.php

示例3: getActiveLanguage

 public static function getActiveLanguage()
 {
     global $cAvailableLanguages;
     // look in the order of most volatile first - if we find something, use it.
     // request cache
     if (self::$requestLanguage != "") {
         return self::$requestLanguage;
     }
     // get parameter
     $getParam = WebRequest::get("lang");
     if ($getParam != false) {
         // check value is in list of allowed values
         if (array_key_exists($getParam, $cAvailableLanguages)) {
             // save local cache for other messages this request
             self::$requestLanguage = $getParam;
             // set a cookie to persist that option for this session (do we want
             // this option to set the preferences too?)
             WebRequest::setCookie("lang", $getParam);
             // use this value.
             return $getParam;
         }
     }
     // cookie
     $cookie = WebRequest::getCookie("lang");
     if ($cookie != false) {
         // check value is in list of allowed values
         if (array_key_exists($cookie, $cAvailableLanguages)) {
             // save local cache for other messages this request
             self::$requestLanguage = $cookie;
             // use this value.
             return $cookie;
         }
     }
     // user preference
     // site default
     return "en-GB";
 }
开发者ID:vulnerabilityCode,项目名称:hotel-system,代码行数:37,代码来源:Message.php

示例4: isBeta

 public static function isBeta(WebRequest $request)
 {
     $tux = $request->getVal('tux', null);
     if ($tux === null) {
         $tux = $request->getCookie('tux', null, true);
     } elseif ($tux) {
         $request->response()->setCookie('tux', 1);
     } else {
         $request->response()->setCookie('tux', 0);
     }
     return $tux;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:12,代码来源:SpecialTranslate.php

示例5: suggestLoginUsername

 public function suggestLoginUsername(WebRequest $request)
 {
     return $request->getCookie('UserName');
 }
开发者ID:Gomyul,项目名称:mediawiki,代码行数:4,代码来源:DummySessionProvider.php


注:本文中的WebRequest::getCookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。