/**
  * Remove the garbage from the session if necessary.
  *
  * @param  \Illuminate\Session\SessionInterface  $session
  * @return void
  */
 protected function collectGarbage(SessionInterface $session)
 {
     $config = $this->manager->getSessionConfig();
     // Here we will see if this request hits the garbage collection lottery by hitting
     // the odds needed to perform garbage collection on any given request. If we do
     // hit it, we'll call this handler to let it delete all the expired sessions.
     if ($this->configHitsLottery($config)) {
         $session->getHandler()->gc($this->getLifetimeSeconds());
     }
 }
 /**
  * @return array|string
  */
 public function encode()
 {
     if ($this->session->has($this->flash_key)) {
     }
     $messages = $this->session->get($this->flash_key);
     if ($messages == null) {
         return json_encode([]);
     }
     $this->session->set($this->flash_key, []);
     $encoded_messages = [];
     foreach ($messages as $msg) {
         array_push($encoded_messages, $msg->encode());
     }
     $encoded_messages = '[' . implode(',', $encoded_messages) . ']';
     return $encoded_messages;
     return json_encode([]);
 }
 /**
  * Add the session cookie to the application response.
  *
  * @param  \Symfony\Component\HttpFoundation\Response  $response
  * @param  \Illuminate\Session\SessionInterface  $session
  * @return void
  */
 protected function addCookieToResponse(Response $response, SessionInterface $session)
 {
     if ($this->usingCookieSessions()) {
         $this->manager->driver()->save();
     }
     if ($this->sessionIsPersistent($config = $this->manager->getSessionConfig())) {
         $response->headers->setCookie(new Cookie($session->getName(), $session->getId(), $this->getCookieExpirationDate(), $config['path'], $config['domain'], array_get($config, 'secure', false)));
     }
 }
Beispiel #4
0
 /**
  * Determine if the old input is empty.
  *
  * @return bool
  */
 public function oldInputIsEmpty()
 {
     return isset($this->session) && count($this->session->getOldInput()) == 0;
 }
 /**
  * session 정보 업데이트
  *
  * @param array $session session information
  * @return void
  */
 private function putSession($session)
 {
     $this->session->set(self::SESSION_NAME, array_merge($this->session->get(self::SESSION_NAME), [$this->name => $session]));
 }
 /**
  * Updating Session info for a user
  * @param SessionInterface $session
  */
 public static function updateUserDataSession(SessionInterface $session, UserModel $user)
 {
     $user->user_id != "" ? $session->set(self::USER_ID, $user->user_id) : "";
     $user->name != "" ? $session->set(self::FULL_NAME, $user->name) : "";
     $user->email != "" ? $session->set(self::EMAIL_ADDRESS, $user->email) : "";
 }
Beispiel #7
0
 /**
  * Generate a hidden field with the current CSRF token.
  *
  * @return \Illuminate\Support\HtmlString
  */
 public function token()
 {
     $token = !empty($this->csrfToken) ? $this->csrfToken : $this->session->getToken();
     return $this->hidden('_token', $token);
 }
 /**
  * {@inheritdoc}
  */
 protected function addIdentifierToResponse(Response $response, SessionInterface $session)
 {
     if ($this->sessionIsPersistent($config = $this->manager->getSessionConfig())) {
         $response->headers->set("X-Session-Token", $session->getId());
     }
 }
 public function set($key, $value)
 {
     $this->session->set($this->prefix_key . $key, $value);
 }
 /**
  * Store the current URL for the request if necessary.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Illuminate\Session\SessionInterface $session
  * @return void
  */
 protected function storeCurrentUrl(Request $request, $session)
 {
     if ($request->method() === 'GET' && $request->route() && !$request->ajax() && $request->route()->getName() != 'files.show' && $request->route()->getName() != '.api' && !str_contains($request->route()->getName(), 'debugbar')) {
         $session->setPreviousUrl($request->fullUrl());
     }
 }