SessionInterface.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /**
  3. * @package Grav\Framework\Session
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Framework\Session;
  9. /**
  10. * Class Session
  11. * @package Grav\Framework\Session
  12. */
  13. interface SessionInterface extends \IteratorAggregate
  14. {
  15. /**
  16. * Get current session instance.
  17. *
  18. * @return Session
  19. * @throws \RuntimeException
  20. */
  21. public static function getInstance();
  22. /**
  23. * Get session ID
  24. *
  25. * @return string|null Session ID
  26. */
  27. public function getId();
  28. /**
  29. * Set session ID
  30. *
  31. * @param string $id Session ID
  32. *
  33. * @return $this
  34. */
  35. public function setId($id);
  36. /**
  37. * Get session name
  38. *
  39. * @return string|null
  40. */
  41. public function getName();
  42. /**
  43. * Set session name
  44. *
  45. * @param string $name
  46. *
  47. * @return $this
  48. */
  49. public function setName($name);
  50. /**
  51. * Sets session.* ini variables.
  52. *
  53. * @param array $options
  54. *
  55. * @see http://php.net/session.configuration
  56. */
  57. public function setOptions(array $options);
  58. /**
  59. * Starts the session storage
  60. *
  61. * @param bool $readonly
  62. * @return $this
  63. * @throws \RuntimeException
  64. */
  65. public function start($readonly = false);
  66. /**
  67. * Invalidates the current session.
  68. *
  69. * @return $this
  70. */
  71. public function invalidate();
  72. /**
  73. * Force the session to be saved and closed
  74. *
  75. * @return $this
  76. */
  77. public function close();
  78. /**
  79. * Free all session variables.
  80. *
  81. * @return $this
  82. */
  83. public function clear();
  84. /**
  85. * Returns all session variables.
  86. *
  87. * @return array
  88. */
  89. public function getAll();
  90. /**
  91. * Retrieve an external iterator
  92. *
  93. * @return \ArrayIterator Return an ArrayIterator of $_SESSION
  94. */
  95. public function getIterator();
  96. /**
  97. * Checks if the session was started.
  98. *
  99. * @return bool
  100. */
  101. public function isStarted();
  102. /**
  103. * Checks if session variable is defined.
  104. *
  105. * @param string $name
  106. * @return bool
  107. */
  108. public function __isset($name);
  109. /**
  110. * Returns session variable.
  111. *
  112. * @param string $name
  113. * @return mixed
  114. */
  115. public function __get($name);
  116. /**
  117. * Sets session variable.
  118. *
  119. * @param string $name
  120. * @param mixed $value
  121. */
  122. public function __set($name, $value);
  123. /**
  124. * Removes session variable.
  125. *
  126. * @param string $name
  127. */
  128. public function __unset($name);
  129. }