SessionHandlerInterface.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 compatibility 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. public function open($savePath, $sessionName);
  38. /**
  39. * Close session.
  40. *
  41. * @see http://php.net/sessionhandlerinterface.close
  42. *
  43. * @return boolean
  44. */
  45. public function close();
  46. /**
  47. * Read session.
  48. *
  49. * @param string $sessionId
  50. *
  51. * @see http://php.net/sessionhandlerinterface.read
  52. *
  53. * @throws \RuntimeException On fatal error but not "record not found".
  54. *
  55. * @return string String as stored in persistent storage or empty string in all other cases.
  56. */
  57. public function read($sessionId);
  58. /**
  59. * Commit session to storage.
  60. *
  61. * @see http://php.net/sessionhandlerinterface.write
  62. *
  63. * @param string $sessionId Session ID.
  64. * @param string $data Session serialized data to save.
  65. *
  66. * @return boolean
  67. */
  68. public function write($sessionId, $data);
  69. /**
  70. * Destroys this session.
  71. *
  72. * @see http://php.net/sessionhandlerinterface.destroy
  73. *
  74. * @param string $sessionId Session ID.
  75. *
  76. * @throws \RuntimeException On fatal error.
  77. *
  78. * @return boolean
  79. */
  80. public function destroy($sessionId);
  81. /**
  82. * Garbage collection for storage.
  83. *
  84. * @see http://php.net/sessionhandlerinterface.gc
  85. *
  86. * @param integer $lifetime Max lifetime in seconds to keep sessions stored.
  87. *
  88. * @throws \RuntimeException On fatal error.
  89. *
  90. * @return boolean
  91. */
  92. public function gc($lifetime);
  93. }