NullSessionHandler.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
  11. /**
  12. * Can be used in unit testing or in a situations where persisted sessions are not desired.
  13. *
  14. * @author Drak <drak@zikula.org>
  15. */
  16. class NullSessionHandler extends AbstractSessionHandler
  17. {
  18. public function close(): bool
  19. {
  20. return true;
  21. }
  22. public function validateId(string $sessionId): bool
  23. {
  24. return true;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. protected function doRead(string $sessionId): string
  30. {
  31. return '';
  32. }
  33. public function updateTimestamp(string $sessionId, string $data): bool
  34. {
  35. return true;
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. protected function doWrite(string $sessionId, string $data): bool
  41. {
  42. return true;
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. protected function doDestroy(string $sessionId): bool
  48. {
  49. return true;
  50. }
  51. public function gc(int $maxlifetime): int|false
  52. {
  53. return 0;
  54. }
  55. }