/** * @param $key * * @return Cookie */ public function getCookie($key) { if ($cookieValue = $this->request->cookies()->get($key)) { $cookie = new Cookie(); $cookie->setName($key); $cookie->setValue($cookieValue); return $cookie; } return null; }
/** * @param Cookie $cookie * @return mixed */ public function addCookie(Cookie $cookie) { $kleinCookie = new ResponseCookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiration(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); $this->klein->response()->cookies()->set($cookie->getName(), $kleinCookie); }
public function saveCookie(BrowserSessionEntity $browserSession) { $config = $this->getConfig(); $cookie = new Cookie(); $cookie->setName(BrowserSessionEntity::COOKIE_KEY); $cookie->setValue($browserSession->getToken()); $cookie->setExpiration($browserSession->getExpirationDate()); $cookie->setPath($config->getPath()); $cookie->setDomain($config->getDomain()); $cookie->setIsSecure($config->isSecure()); $cookie->setIsHttpOnly($config->isHttponly()); $this->getRouterDriver()->addCookie($cookie); }