/** * function called via ajax everytime user performs search * * @param string $city */ public function handleSaveSearch($city) { $userCookie = $this->httpRequest->getCookie('rabbit_user'); $user = $this->userRepository->findBy(['hash' => $userCookie])->fetch(); // check if user performed search of this city in past $userSearchExist = $this->historyRepository->findBy(['user_id' => $user->id, 'city' => $city]); // if yes, then only update datetime of this search ... otherwise insert new one if ($userSearchExist->fetchAll()) { $this->historyRepository->update($userSearchExist->fetch()->id, ['performed' => \Nette\Utils\DateTime::from('now')]); } else { $this->historyRepository->insert(['user_id' => $user->id, 'city' => $city, 'performed' => \Nette\Utils\DateTime::from('now')]); } $searchRecords = $this->historyRepository->findBy(['user_id' => $user->id])->order('performed DESC')->fetchAll(); $this->template->searchRecords = $searchRecords; $this->redrawControl('historyList'); }
/** * Parses the metadata cookie that our Javascript API set * * @return array */ protected function getMetadataCookie() { $cookieName = $this->config->getMetadataCookieName(); // The cookie value can be wrapped in "-characters so remove them if (!($cookieValue = trim($this->httpRequest->getCookie($cookieName), '"'))) { return array(); } parse_str($cookieValue, $metadata); array_walk($metadata, function (&$value, &$key) { $value = urldecode($value); $key = urldecode($key); }); return $metadata; }
/** * Loads JWT from HTTP cookie and stores the data into the $jwtData variable. * @return array|bool The JWT data as array or FALSE if there is no JWT cookie. */ private function loadJWTCookie() { if ($this->cookieSaved) { return true; } $jwtCookie = $this->request->getCookie(self::COOKIE_NAME); if (!$jwtCookie) { $this->logoutReason = self::INACTIVITY | self::BROWSER_CLOSED; return false; } try { $this->jwtData = (array) $this->jwtService->decode($jwtCookie, $this->privateKey, [$this->algorithm]); } catch (ExpiredException $e) { $this->logoutReason = self::INACTIVITY; return false; } return $this->jwtData; }
/** * @param Nette\Http\Request $request * @return array Http parametry hlasujiciho uzivatele */ protected function getRequestInfo($request) { $result = ['ip' => $request->getRemoteAddress(), 'agent' => $request->getHeader('user-agent'), 'cookie' => $request->getCookie('nette-browser')]; return $result; }
public function getCookie($key, $default = null) { return $this->request->getCookie($key, $default); }
/** * Get cookie with last cosial login * @return mixed */ public function getSocialLoginCookie() { return $this->httpRequest->getCookie($this->cookieName); }