當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。