NullSessionHandler.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. /**
  19. * @return bool
  20. */
  21. #[\ReturnTypeWillChange]
  22. public function close()
  23. {
  24. return true;
  25. }
  26. /**
  27. * @return bool
  28. */
  29. #[\ReturnTypeWillChange]
  30. public function validateId($sessionId)
  31. {
  32. return true;
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. protected function doRead(string $sessionId)
  38. {
  39. return '';
  40. }
  41. /**
  42. * @return bool
  43. */
  44. #[\ReturnTypeWillChange]
  45. public function updateTimestamp($sessionId, $data)
  46. {
  47. return true;
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. protected function doWrite(string $sessionId, string $data)
  53. {
  54. return true;
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. protected function doDestroy(string $sessionId)
  60. {
  61. return true;
  62. }
  63. /**
  64. * @return int|false
  65. */
  66. #[\ReturnTypeWillChange]
  67. public function gc($maxlifetime)
  68. {
  69. return 0;
  70. }
  71. }