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


PHP Request::getCookie方法代码示例

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


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

示例1: create

 public static function create(HttpRequest $request)
 {
     $queryParams = $request->getQuery()->toArray();
     $postParams = $request->getPost()->toArray();
     $files = $request->getFiles()->toArray();
     $cookies = ($c = $request->getCookie()) ? [$c] : [];
     return new OAuth2Request($queryParams, $postParams, [], $cookies, $files, $_SERVER);
 }
开发者ID:eschwartz,项目名称:ZfAuth,代码行数:8,代码来源:OAuth2RequestFactory.php

示例2: fromZend

 /**
  * Convert a Zend\Http\Response in a PSR-7 response, using zend-diactoros
  *
  * @param  ZendRequest $zendRequest
  * @return ServerRequest
  */
 public static function fromZend(ZendRequest $zendRequest)
 {
     $body = new Stream('php://memory', 'wb+');
     $body->write($zendRequest->getContent());
     $headers = empty($zendRequest->getHeaders()) ? [] : $zendRequest->getHeaders()->toArray();
     $query = empty($zendRequest->getQuery()) ? [] : $zendRequest->getQuery()->toArray();
     $post = empty($zendRequest->getPost()) ? [] : $zendRequest->getPost()->toArray();
     $files = empty($zendRequest->getFiles()) ? [] : $zendRequest->getFiles()->toArray();
     $request = new ServerRequest([], self::convertFilesToUploaded($files), $zendRequest->getUriString(), $zendRequest->getMethod(), $body, $headers);
     $request = $request->withQueryParams($query);
     $cookie = $zendRequest->getCookie();
     if (false !== $cookie) {
         $request = $request->withCookieParams($cookie->getArrayCopy());
     }
     return $request->withParsedBody($post);
 }
开发者ID:zendframework,项目名称:zend-psr7bridge,代码行数:22,代码来源:Psr7ServerRequest.php

示例3: read

 /**
  * @param Request $request
  * @param Response|null $response
  * @return SerieTokenInterface|null
  */
 public function read(Request $request, Response $response = null)
 {
     $cookie = $request->getCookie();
     if (!isset($cookie[self::COOKIE_NAME])) {
         return null;
     }
     $parts = explode(':', $cookie[self::COOKIE_NAME]);
     if (!is_array($parts) || count($parts) !== 3) {
         if ($response) {
             $this->writeNull($response);
         }
         return null;
     }
     $serieTokenEntityClass = $this->getModuleOptions()->getSerieTokenEntityClass();
     $serieToken = new $serieTokenEntityClass();
     $serieToken->setUserId($parts[0]);
     $serieToken->setSerie($parts[1]);
     $serieToken->setToken($parts[2]);
     return $serieToken;
 }
开发者ID:roelvanduijnhoven,项目名称:JwPersistentUser,代码行数:25,代码来源:CookieService.php

示例4: hasIndicator

 protected function hasIndicator()
 {
     $cookie = $this->request->getCookie();
     if (!is_object($cookie)) {
         return false;
     }
     if ($cookie->offsetExists($this->cookieName) && $cookie->offsetGet($this->cookieName)) {
         return true;
     }
     $cookies = $this->response->getCookie();
     if (!is_array($cookies)) {
         return false;
     }
     foreach ($cookies as $cookie) {
         if ($cookie->getName() === $this->cookieName && $cookie->getValue() === true) {
             return true;
         }
     }
     return false;
 }
开发者ID:andreas-serlo,项目名称:athene2,代码行数:20,代码来源:AuthenticationService.php

示例5: authenticate

 /**
  * Attempt to authenticate the current request.
  *
  * @param Request $request
  * @param Response $response
  * @param MvcAuthEvent $mvcAuthEvent
  * @return false|Identity\IdentityInterface False on failure, IdentityInterface
  *     otherwise
  */
 public function authenticate(Request $request, Response $response, MvcAuthEvent $mvcAuthEvent)
 {
     $oauth2request = new OAuth2Request($request->getQuery()->toArray(), $request->getPost()->toArray(), [], $request->getCookie() ? $request->getCookie()->getArrayCopy() : [], $request->getFiles() ? $request->getFiles()->toArray() : [], method_exists($request, 'getServer') ? $request->getServer()->toArray() : $_SERVER, $request->getContent(), $request->getHeaders()->toArray());
     // Failure to validate
     if (!$this->oauth2Server->verifyResourceRequest($oauth2request)) {
         $oauth2Response = $this->oauth2Server->getResponse();
         $status = $oauth2Response->getStatusCode();
         // 401 or 403 mean invalid credentials or unauthorized scopes; report those.
         if (in_array($status, [401, 403], true) && null !== $oauth2Response->getParameter('error')) {
             return $this->mergeOAuth2Response($status, $response, $oauth2Response);
         }
         // Merge in any headers; typically sets a WWW-Authenticate header.
         $this->mergeOAuth2ResponseHeaders($response, $oauth2Response->getHttpHeaders());
         // Otherwise, no credentials were present at all, so we just return a guest identity.
         return new Identity\GuestIdentity();
     }
     $token = $this->oauth2Server->getAccessTokenData($oauth2request);
     $identity = new Identity\AuthenticatedIdentity($token);
     $identity->setName($token['user_id']);
     return $identity;
 }
开发者ID:nuxwin,项目名称:zf-mvc-auth,代码行数:30,代码来源:OAuth2Adapter.php

示例6: initUser

 /**
  * 
  * @param \Zend\Http\Request $request
  * @return \entity\User | null
  */
 public function initUser(\Zend\Http\Request $request)
 {
     $user = null;
     //first access to application
     //Log based on POST parameters
     if (!empty($request->getPost('LITEFRAMESESSIONID')) && classes_utils_session::getSessionId($request->getPost('LITEFRAMESESSIONID'), $request->getCookie()['PHPSESSID']) && $request->getCookie()['PHPSESSID'] == classes_utils_session::getPhpSessionId($request->getPost('LITEFRAMESESSIONID'))) {
         $sessionId = $request->getPost('LITEFRAMESESSIONID');
         $userId = classes_utils_session::getUserIdBySessionId($sessionId);
         classes_utils_session::deleteOldSessionId($userId, $sessionId, $_COOKIE['PHPSESSID']);
         $this->login($sessionId, $userId);
         $this->setLoged(true);
         $user = $this->getEntity($this->dao->find($userId), new \entity\User());
     } elseif (!empty($_SESSION['LITEFRAMESESSIONID']) && classes_utils_session::getSessionId($_SESSION['LITEFRAMESESSIONID'], $_COOKIE['PHPSESSID']) && $_COOKIE['PHPSESSID'] == classes_utils_session::getPhpSessionId($_SESSION['LITEFRAMESESSIONID'])) {
         $sessionId = $_SESSION['LITEFRAMESESSIONID'];
         $userId = classes_utils_session::getUserIdBySessionId($sessionId);
         classes_utils_session::deleteOldSessionId($userId, $sessionId, $_COOKIE['PHPSESSID']);
         $this->login($sessionId, $userId);
         $this->sessionId = $sessionId;
         $this->setLoged(true);
         $user = $this->getEntity($this->dao->find($userId), new \entity\User());
     } else {
         $this->setLoged(false);
     }
     return $user;
 }
开发者ID:6975usa,项目名称:admin,代码行数:30,代码来源:UserService.php


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