コード例 #1
0
 /**
  * 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());
     }
 }
コード例 #2
0
 /**
  * @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([]);
 }
コード例 #3
0
 /**
  * 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)));
     }
 }
コード例 #4
0
ファイル: Html.php プロジェクト: huglester/streams-platform
 /**
  * Determine if the old input is empty.
  *
  * @return bool
  */
 public function oldInputIsEmpty()
 {
     return isset($this->session) && count($this->session->getOldInput()) == 0;
 }
コード例 #5
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]));
 }
コード例 #6
0
 /**
  * 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) : "";
 }
コード例 #7
0
ファイル: FormBuilder.php プロジェクト: ARCANEDEV/LaravelHtml
 /**
  * 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);
 }
コード例 #8
0
 /**
  * {@inheritdoc}
  */
 protected function addIdentifierToResponse(Response $response, SessionInterface $session)
 {
     if ($this->sessionIsPersistent($config = $this->manager->getSessionConfig())) {
         $response->headers->set("X-Session-Token", $session->getId());
     }
 }
コード例 #9
0
 public function set($key, $value)
 {
     $this->session->set($this->prefix_key . $key, $value);
 }
コード例 #10
0
 /**
  * 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());
     }
 }