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


PHP Session::invalidate方法代码示例

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


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

示例1: onAccessDeniedException

 /**
  * @param GetResponseForExceptionEvent $event
  */
 public function onAccessDeniedException(GetResponseForExceptionEvent $event)
 {
     if ($event->getException() instanceof AccessDeniedHttpException) {
         $this->session->invalidate();
         $this->session->set(SecurityContextInterface::ACCESS_DENIED_ERROR, ['message' => 'You are not allowed']);
         $this->securityContext->setToken(null);
         $route = $this->router->generate('oro_distribution_security_login');
         $event->setResponse(new RedirectResponse($route));
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:AccessDeniedListener.php

示例2: logout

 /**
  * @param boolean $destroy
  *
  * @return boolean
  */
 public function logout($destroy = false)
 {
     if ($destroy === true) {
         $this->session->invalidate();
     } else {
         $this->session->remove(self::USER_ID);
         $this->session->remove(self::USER_NAME);
         $this->session->remove(self::USER_GROUPS);
         $this->session->migrate();
     }
     return !$this->isLogin();
 }
开发者ID:corpsee,项目名称:nameless-source,代码行数:17,代码来源:User.php

示例3: handleSessionValidation

 /**
  * @param \Symfony\Component\HttpFoundation\Session\Session $session
  */
 public function handleSessionValidation(SymfonySession $session)
 {
     $ip_address = new IPAddress($this->request->getClientIp());
     $request_ip = $ip_address->getIp(IPAddress::FORMAT_IP_STRING);
     $invalidate = false;
     $ip = $session->get('CLIENT_REMOTE_ADDR');
     $agent = $session->get('CLIENT_HTTP_USER_AGENT');
     $request_agent = $this->request->server->get('HTTP_USER_AGENT');
     // Validate the request IP
     if ($this->shouldCompareIP() && $ip && $ip != $request_ip) {
         if ($this->logger) {
             $this->logger->debug('Session Invalidated. Session IP "{session}" did not match provided IP "{client}".', array('session' => $ip, 'client' => $request_ip));
         }
         $invalidate = true;
     }
     // Validate the request user agent
     if ($this->shouldCompareAgent() && $agent && $agent != $request_agent) {
         if ($this->logger) {
             $this->logger->debug('Session Invalidated. Session user agent "{session}" did not match provided agent "{client}"', array('session' => $agent, 'client' => $request_agent));
         }
         $invalidate = true;
     }
     if ($invalidate) {
         $session->invalidate();
     } else {
         if (!$ip && $request_ip) {
             $session->set('CLIENT_REMOTE_ADDR', $request_ip);
         }
         if (!$agent && $request_agent) {
             $session->set('CLIENT_HTTP_USER_AGENT', $request_agent);
         }
     }
 }
开发者ID:digideskio,项目名称:concrete5,代码行数:36,代码来源:SessionValidator.php

示例4: doLogout

 /**
  * Perform the logout, resetting the session
  */
 public function doLogout()
 {
     $this->deleteRememberMeCookie();
     $this->session->clear();
     $this->session->invalidate();
     $this->user_is_logged_in = false;
 }
开发者ID:khaidir,项目名称:phpservermon,代码行数:10,代码来源:User.class.php

示例5: initializeSession

 /**
  * Initialize the session.
  *
  * This is something you might want to override in your controller so you can
  * redirect to a page with a message about being logged out after detecting the session has expired.
  *
  * @var int $session_expiration Session Expiration in seconds
  */
 protected function initializeSession($session_expiration = null)
 {
     /**
      * Setup the session with cookie expiration of one week. This will
      * allow the session to persist even if the browser window is closed.
      * The session expiration will still be respected (default 1 hour).
      */
     $this->session = new Session(new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage(['cookie_lifetime' => 604800]));
     $this->config->load('config');
     // Should session cookie be http only? Default true to reduce XSS attack vector.
     $session_cookie_httponly = (bool) $this->config->get('session_cookie_httponly', true);
     ini_set('session.cookie_httponly', $session_cookie_httponly);
     // We need a unique session name for this app. Let's use last 10 characters the file path's sha1 hash.
     try {
         $this->session->setName('TSAPP' . substr(sha1(__FILE__), -10));
         $this->session->start();
         // Default session expiration 1 hour.
         // Can be overridden in method param or by setting session_expiration in config.php
         $session_expiration = !empty($session_expiration) ? $session_expiration : $this->config->get('session_expiration', 3600);
         // Is this session too old?
         if (time() - $this->session->getMetadataBag()->getLastUsed() > $session_expiration) {
             $this->session->invalidate();
         }
     } catch (\LogicException $e) {
         // Session already active, can't change it now!
     }
 }
开发者ID:werx,项目名称:core,代码行数:35,代码来源:Controller.php

示例6: logoutAction

 /**
  * @Route("/wylogowanie")
  */
 public function logoutAction()
 {
     $session = new Session();
     $session->invalidate();
     setcookie('login', '', 0, '/');
     return $this->redirectToRoute('loginpage');
 }
开发者ID:eerie79,项目名称:fachowcy_svn,代码行数:10,代码来源:LogoutController.php

示例7: logoutAction

 public function logoutAction(Session $session)
 {
     $session->invalidate();
     $session->getFlashBag()->add('success', "You logged out successfully");
     // Don't redirect back but prefer going home, to prevent visiting
     // the login page (and logging in again, thus preventing the logout)
     // or other pages where authentication is required
     return $this->goHome();
 }
开发者ID:blast007,项目名称:bzion,代码行数:9,代码来源:LoginController.php

示例8: testSessionFixation

 protected static function testSessionFixation(SymfonySession $session)
 {
     $ip = $session->get('CLIENT_REMOTE_ADDR');
     $agent = $session->get('CLIENT_HTTP_USER_AGENT');
     if ($ip && $ip != $_SERVER['REMOTE_ADDR'] || $agent && $agent != $_SERVER['HTTP_USER_AGENT']) {
         $session->invalidate();
     }
     if (!$ip && isset($_SERVER['REMOTE_ADDR'])) {
         $session->set('CLIENT_REMOTE_ADDR', $_SERVER['REMOTE_ADDR']);
     }
     if (!$agent && isset($_SERVER['HTTP_USER_AGENT'])) {
         $session->set('CLIENT_HTTP_USER_AGENT', $_SERVER['HTTP_USER_AGENT']);
     }
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:14,代码来源:Session.php

示例9: applySessionStrategy

 /**
  * Apply the Session Strategy
  *
  * @return void
  */
 protected function applySessionStrategy()
 {
     if (!$this->session->isStarted()) {
         return $this->session->start();
     }
     switch ($this->strategy) {
         case self::STRATEGY_MIGRATE:
             $this->session->migrate();
             break;
         case self::STRATEGY_INVALIDATES:
             $this->session->invalidate();
             break;
         default:
             throw new \RuntimeException('Session strategy should be "migrate" or "invalidate"');
     }
 }
开发者ID:fwk,项目名称:security,代码行数:21,代码来源:SessionStorage.php

示例10: testSessionFixation

 protected static function testSessionFixation(SymfonySession $session)
 {
     $iph = Core::make('helper/validation/ip');
     $currentIp = $iph->getRequestIP();
     $ip = $session->get('CLIENT_REMOTE_ADDR');
     $agent = $session->get('CLIENT_HTTP_USER_AGENT');
     if ($ip && $ip != $currentIp->getIp(IPAddress::FORMAT_IP_STRING) || $agent && $agent != $_SERVER['HTTP_USER_AGENT']) {
         $session->invalidate();
     }
     if (!$ip && $currentIp !== false) {
         $session->set('CLIENT_REMOTE_ADDR', $currentIp->getIp(IPAddress::FORMAT_IP_STRING));
     }
     if (!$agent && isset($_SERVER['HTTP_USER_AGENT'])) {
         $session->set('CLIENT_HTTP_USER_AGENT', $_SERVER['HTTP_USER_AGENT']);
     }
 }
开发者ID:ngreimel,项目名称:kovent,代码行数:16,代码来源:Session.php

示例11: checkSession

 /**
  * Função para validar a sessão
  *
  * @param Session $session
  * @return bool
  */
 public function checkSession(Session $session)
 {
     $logger = $this->get('logger');
     $session->getMetadataBag()->getCreated();
     $session->getMetadataBag()->getLastUsed();
     if (time() - $session->getMetadataBag()->getLastUsed() > $this->maxIdleTime) {
         $session->invalidate();
         $logger->error("Sessão inválida:\n" . $session->getId());
         //throw new SessionExpired(); // direciona para a página de sessão expirada
         return false;
     } else {
         return true;
     }
 }
开发者ID:mistercomputer,项目名称:cacic,代码行数:20,代码来源:NeoController.php

示例12: logout

 /**
  * Destroy the user session
  */
 function logout()
 {
     $this->session->invalidate();
 }
开发者ID:mystlabs,项目名称:mistyapp,代码行数:7,代码来源:SessionManager.php

示例13: invalidate

 /**
  * {@inheritdoc}
  */
 public function invalidate($lifetime = null)
 {
     parent::start();
     return parent::invalidate($lifetime);
 }
开发者ID:beaast-com,项目名称:beaast-core,代码行数:8,代码来源:NonblockingSession.php


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