Session.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. namespace Illuminate\Contracts\Session;
  3. interface Session
  4. {
  5. /**
  6. * Get the name of the session.
  7. *
  8. * @return string
  9. */
  10. public function getName();
  11. /**
  12. * Set the name of the session.
  13. *
  14. * @param string $name
  15. * @return void
  16. */
  17. public function setName($name);
  18. /**
  19. * Get the current session ID.
  20. *
  21. * @return string
  22. */
  23. public function getId();
  24. /**
  25. * Set the session ID.
  26. *
  27. * @param string $id
  28. * @return void
  29. */
  30. public function setId($id);
  31. /**
  32. * Start the session, reading the data from a handler.
  33. *
  34. * @return bool
  35. */
  36. public function start();
  37. /**
  38. * Save the session data to storage.
  39. *
  40. * @return void
  41. */
  42. public function save();
  43. /**
  44. * Get all of the session data.
  45. *
  46. * @return array
  47. */
  48. public function all();
  49. /**
  50. * Checks if a key exists.
  51. *
  52. * @param string|array $key
  53. * @return bool
  54. */
  55. public function exists($key);
  56. /**
  57. * Checks if a key is present and not null.
  58. *
  59. * @param string|array $key
  60. * @return bool
  61. */
  62. public function has($key);
  63. /**
  64. * Get an item from the session.
  65. *
  66. * @param string $key
  67. * @param mixed $default
  68. * @return mixed
  69. */
  70. public function get($key, $default = null);
  71. /**
  72. * Get the value of a given key and then forget it.
  73. *
  74. * @param string $key
  75. * @param mixed $default
  76. * @return mixed
  77. */
  78. public function pull($key, $default = null);
  79. /**
  80. * Put a key / value pair or array of key / value pairs in the session.
  81. *
  82. * @param string|array $key
  83. * @param mixed $value
  84. * @return void
  85. */
  86. public function put($key, $value = null);
  87. /**
  88. * Get the CSRF token value.
  89. *
  90. * @return string
  91. */
  92. public function token();
  93. /**
  94. * Regenerate the CSRF token value.
  95. *
  96. * @return void
  97. */
  98. public function regenerateToken();
  99. /**
  100. * Remove an item from the session, returning its value.
  101. *
  102. * @param string $key
  103. * @return mixed
  104. */
  105. public function remove($key);
  106. /**
  107. * Remove one or many items from the session.
  108. *
  109. * @param string|array $keys
  110. * @return void
  111. */
  112. public function forget($keys);
  113. /**
  114. * Remove all of the items from the session.
  115. *
  116. * @return void
  117. */
  118. public function flush();
  119. /**
  120. * Flush the session data and regenerate the ID.
  121. *
  122. * @return bool
  123. */
  124. public function invalidate();
  125. /**
  126. * Generate a new session identifier.
  127. *
  128. * @param bool $destroy
  129. * @return bool
  130. */
  131. public function regenerate($destroy = false);
  132. /**
  133. * Generate a new session ID for the session.
  134. *
  135. * @param bool $destroy
  136. * @return bool
  137. */
  138. public function migrate($destroy = false);
  139. /**
  140. * Determine if the session has been started.
  141. *
  142. * @return bool
  143. */
  144. public function isStarted();
  145. /**
  146. * Get the previous URL from the session.
  147. *
  148. * @return string|null
  149. */
  150. public function previousUrl();
  151. /**
  152. * Set the "previous" URL in the session.
  153. *
  154. * @param string $url
  155. * @return void
  156. */
  157. public function setPreviousUrl($url);
  158. /**
  159. * Get the session handler instance.
  160. *
  161. * @return \SessionHandlerInterface
  162. */
  163. public function getHandler();
  164. /**
  165. * Determine if the session handler needs a request.
  166. *
  167. * @return bool
  168. */
  169. public function handlerNeedsRequest();
  170. /**
  171. * Set the request on the handler instance.
  172. *
  173. * @param \Illuminate\Http\Request $request
  174. * @return void
  175. */
  176. public function setRequestOnHandler($request);
  177. }