[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Session/ -> SessionManager.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\Session;
  11  
  12  // phpcs:disable PSR1.Files.SideEffects
  13  \defined('JPATH_PLATFORM') or die;
  14  // phpcs:enable PSR1.Files.SideEffects
  15  
  16  /**
  17   * Manager for interacting with the session handler to perform updates on sessions.
  18   *
  19   * @since  4.0.0
  20   */
  21  final class SessionManager
  22  {
  23      /**
  24       * Session handler.
  25       *
  26       * @var    \SessionHandlerInterface
  27       * @since  4.0.0
  28       */
  29      private $sessionHandler;
  30  
  31      /**
  32       * SessionManager constructor.
  33       *
  34       * @param   \SessionHandlerInterface  $sessionHandler  Session handler.
  35       *
  36       * @since   4.0.0
  37       */
  38      public function __construct(\SessionHandlerInterface $sessionHandler)
  39      {
  40          $this->sessionHandler = $sessionHandler;
  41      }
  42  
  43      /**
  44       * Destroys the given session ID.
  45       *
  46       * @param   string  $sessionId  The session ID to destroy.
  47       *
  48       * @return  boolean
  49       *
  50       * @since   4.0.0
  51       */
  52      public function destroySession(string $sessionId): bool
  53      {
  54          return $this->sessionHandler->destroy($sessionId);
  55      }
  56  
  57      /**
  58       * Destroys the given session IDs.
  59       *
  60       * @param   string[]  $sessionIds  The session IDs to destroy.
  61       *
  62       * @return  boolean
  63       *
  64       * @since   4.0.0
  65       */
  66      public function destroySessions(array $sessionIds): bool
  67      {
  68          $result = true;
  69  
  70          foreach ($sessionIds as $sessionId) {
  71              if (!$this->destroySession($sessionId)) {
  72                  $result = false;
  73              }
  74          }
  75  
  76          return $result;
  77      }
  78  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer