SessionHandlerInterface.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /**
  11. * SessionHandlerInterface
  12. *
  13. * Provides forward compatability with PHP 5.4
  14. *
  15. * Extensive documentation can be found at php.net, see links:
  16. *
  17. * @see http://php.net/sessionhandlerinterface
  18. * @see http://php.net/session.customhandler
  19. * @see http://php.net/session-set-save-handler
  20. *
  21. * @author Drak <drak@zikula.org>
  22. */
  23. interface SessionHandlerInterface
  24. {
  25. /**
  26. * Open session.
  27. *
  28. * @see http://php.net/sessionhandlerinterface.open
  29. *
  30. * @param string $savePath Save path.
  31. * @param string $sessionName Session Name.
  32. *
  33. * @throws \RuntimeException If something goes wrong starting the session.
  34. *
  35. * @return boolean
  36. */
  37. function open($savePath, $sessionName);
  38. /**
  39. * Close session.
  40. *
  41. * @see http://php.net/sessionhandlerinterface.close
  42. *
  43. * @return boolean
  44. */
  45. function close();
  46. /**
  47. * Read session.
  48. *
  49. * @see http://php.net/sessionhandlerinterface.read
  50. *
  51. * @throws \RuntimeException On fatal error but not "record not found".
  52. *
  53. * @return string String as stored in persistent storage or empty string in all other cases.
  54. */
  55. function read($sessionId);
  56. /**
  57. * Commit session to storage.
  58. *
  59. * @see http://php.net/sessionhandlerinterface.write
  60. *
  61. * @param string $sessionId Session ID.
  62. * @param string $data Session serialized data to save.
  63. *
  64. * @return boolean
  65. */
  66. function write($sessionId, $data);
  67. /**
  68. * Destroys this session.
  69. *
  70. * @see http://php.net/sessionhandlerinterface.destroy
  71. *
  72. * @param string $sessionId Session ID.
  73. *
  74. * @throws \RuntimeException On fatal error.
  75. *
  76. * @return boolean
  77. */
  78. function destroy($sessionId);
  79. /**
  80. * Garbage collection for storage.
  81. *
  82. * @see http://php.net/sessionhandlerinterface.gc
  83. *
  84. * @param integer $lifetime Max lifetime in seconds to keep sessions stored.
  85. *
  86. * @throws \RuntimeException On fatal error.
  87. *
  88. * @return boolean
  89. */
  90. function gc($lifetime);
  91. }