NullSessionHandler.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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(#[\SensitiveParameter] string $sessionId): bool
  23. {
  24. return true;
  25. }
  26. protected function doRead(#[\SensitiveParameter] string $sessionId): string
  27. {
  28. return '';
  29. }
  30. public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool
  31. {
  32. return true;
  33. }
  34. protected function doWrite(#[\SensitiveParameter] string $sessionId, string $data): bool
  35. {
  36. return true;
  37. }
  38. protected function doDestroy(#[\SensitiveParameter] string $sessionId): bool
  39. {
  40. return true;
  41. }
  42. public function gc(int $maxlifetime): int|false
  43. {
  44. return 0;
  45. }
  46. }