當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RequestInterface::getCookieParams方法代碼示例

本文整理匯總了PHP中Psr\Http\Message\RequestInterface::getCookieParams方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestInterface::getCookieParams方法的具體用法?PHP RequestInterface::getCookieParams怎麽用?PHP RequestInterface::getCookieParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Http\Message\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::getCookieParams方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fetchToken

 /**
  * Fetch the access token
  *
  * @return string|null Base64 encoded JSON Web Token or null if not found.
  */
 public function fetchToken(RequestInterface $request)
 {
     /* If using PHP in CGI mode and non standard environment */
     $server_params = $request->getServerParams();
     if (isset($server_params[$this->options["environment"]])) {
         $message = "Using token from environent";
         $header = $server_params[$this->options["environment"]];
     } else {
         $message = "Using token from request header";
         $header = $request->getHeader("Authorization");
         $header = isset($header[0]) ? $header[0] : "";
     }
     if (preg_match("/Bearer\\s+(.*)\$/i", $header, $matches)) {
         $this->log(LogLevel::DEBUG, $message);
         return $matches[1];
     }
     /* Bearer not found, try a cookie. */
     $cookie_params = $request->getCookieParams();
     if (isset($cookie_params[$this->options["cookie"]])) {
         $this->log(LogLevel::DEBUG, "Using token from cookie");
         $this->log(LogLevel::DEBUG, $cookie_params[$this->options["cookie"]]);
         return $cookie_params[$this->options["cookie"]];
     }
     /* If everything fails log and return false. */
     $this->message = "Token not found";
     $this->log(LogLevel::WARNING, $this->message);
     return false;
 }
開發者ID:djbakerman,項目名稱:botjack,代碼行數:33,代碼來源:JwtAuthentication.php

示例2: fetchToken

 /**
  * Fetch the access token
  *
  * @return string|null Base64 encoded JSON Web Token or null if not found.
  */
 public function fetchToken(RequestInterface $request)
 {
     /* If using PHP in CGI mode and non standard environment */
     $server_params = $request->getServerParams();
     $header = "";
     /* Check for each given environment */
     foreach ((array) $this->options["environment"] as $environment) {
         if (isset($server_params[$environment])) {
             $message = "Using token from environment";
             $header = $server_params[$environment];
         }
     }
     /* Nothing in environment, try header instead */
     if (empty($header)) {
         $message = "Using token from request header";
         $headers = $request->getHeader("Authorization");
         $header = isset($headers[0]) ? $headers[0] : "";
     }
     /* Try apache_request_headers() as last resort */
     if (empty($header) && function_exists("apache_request_headers")) {
         $headers = apache_request_headers();
         $header = isset($headers["Authorization"]) ? $headers["Authorization"] : "";
     }
     if (preg_match("/Bearer\\s+(.*)\$/i", $header, $matches)) {
         $this->log(LogLevel::DEBUG, $message);
         return $matches[1];
     }
     /* Bearer not found, try a cookie. */
     $cookie_params = $request->getCookieParams();
     if (isset($cookie_params[$this->options["cookie"]])) {
         $this->log(LogLevel::DEBUG, "Using token from cookie");
         $this->log(LogLevel::DEBUG, $cookie_params[$this->options["cookie"]]);
         return $cookie_params[$this->options["cookie"]];
     }
     /* If everything fails log and return false. */
     $this->message = "Token not found";
     $this->log(LogLevel::WARNING, $this->message);
     return false;
 }
開發者ID:Walk4Muscle,項目名稱:garyslim3,代碼行數:44,代碼來源:JwtAuthentication.php


注:本文中的Psr\Http\Message\RequestInterface::getCookieParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。