SessionHandlerInterface.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * This file is part of workerman.
  4. *
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the MIT-LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @author walkor<walkor@workerman.net>
  10. * @copyright walkor<walkor@workerman.net>
  11. * @link http://www.workerman.net/
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace Workerman\Protocols\Http\Session;
  15. interface SessionHandlerInterface
  16. {
  17. /**
  18. * Close the session
  19. * @link http://php.net/manual/en/sessionhandlerinterface.close.php
  20. * @return bool <p>
  21. * The return value (usually TRUE on success, FALSE on failure).
  22. * Note this value is returned internally to PHP for processing.
  23. * </p>
  24. * @since 5.4.0
  25. */
  26. public function close();
  27. /**
  28. * Destroy a session
  29. * @link http://php.net/manual/en/sessionhandlerinterface.destroy.php
  30. * @param string $session_id The session ID being destroyed.
  31. * @return bool <p>
  32. * The return value (usually TRUE on success, FALSE on failure).
  33. * Note this value is returned internally to PHP for processing.
  34. * </p>
  35. * @since 5.4.0
  36. */
  37. public function destroy($session_id);
  38. /**
  39. * Cleanup old sessions
  40. * @link http://php.net/manual/en/sessionhandlerinterface.gc.php
  41. * @param int $maxlifetime <p>
  42. * Sessions that have not updated for
  43. * the last maxlifetime seconds will be removed.
  44. * </p>
  45. * @return bool <p>
  46. * The return value (usually TRUE on success, FALSE on failure).
  47. * Note this value is returned internally to PHP for processing.
  48. * </p>
  49. * @since 5.4.0
  50. */
  51. public function gc($maxlifetime);
  52. /**
  53. * Initialize session
  54. * @link http://php.net/manual/en/sessionhandlerinterface.open.php
  55. * @param string $save_path The path where to store/retrieve the session.
  56. * @param string $name The session name.
  57. * @return bool <p>
  58. * The return value (usually TRUE on success, FALSE on failure).
  59. * Note this value is returned internally to PHP for processing.
  60. * </p>
  61. * @since 5.4.0
  62. */
  63. public function open($save_path, $name);
  64. /**
  65. * Read session data
  66. * @link http://php.net/manual/en/sessionhandlerinterface.read.php
  67. * @param string $session_id The session id to read data for.
  68. * @return string <p>
  69. * Returns an encoded string of the read data.
  70. * If nothing was read, it must return an empty string.
  71. * Note this value is returned internally to PHP for processing.
  72. * </p>
  73. * @since 5.4.0
  74. */
  75. public function read($session_id);
  76. /**
  77. * Write session data
  78. * @link http://php.net/manual/en/sessionhandlerinterface.write.php
  79. * @param string $session_id The session id.
  80. * @param string $session_data <p>
  81. * The encoded session data. This data is the
  82. * result of the PHP internally encoding
  83. * the $_SESSION superglobal to a serialized
  84. * string and passing it as this parameter.
  85. * Please note sessions use an alternative serialization method.
  86. * </p>
  87. * @return bool <p>
  88. * The return value (usually TRUE on success, FALSE on failure).
  89. * Note this value is returned internally to PHP for processing.
  90. * </p>
  91. * @since 5.4.0
  92. */
  93. public function write($session_id, $session_data);
  94. /**
  95. * Update sesstion modify time.
  96. *
  97. * @see https://www.php.net/manual/en/class.sessionupdatetimestamphandlerinterface.php
  98. *
  99. * @param string $id Session id.
  100. * @param string $data Session Data.
  101. *
  102. * @return bool
  103. */
  104. public function updateTimestamp($id, $data = "");
  105. }