Session.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. * Flash a key / value pair to the session.
  89. *
  90. * @param string $key
  91. * @param mixed $value
  92. * @return void
  93. */
  94. public function flash(string $key, $value = true);
  95. /**
  96. * Get the CSRF token value.
  97. *
  98. * @return string
  99. */
  100. public function token();
  101. /**
  102. * Regenerate the CSRF token value.
  103. *
  104. * @return void
  105. */
  106. public function regenerateToken();
  107. /**
  108. * Remove an item from the session, returning its value.
  109. *
  110. * @param string $key
  111. * @return mixed
  112. */
  113. public function remove($key);
  114. /**
  115. * Remove one or many items from the session.
  116. *
  117. * @param string|array $keys
  118. * @return void
  119. */
  120. public function forget($keys);
  121. /**
  122. * Remove all of the items from the session.
  123. *
  124. * @return void
  125. */
  126. public function flush();
  127. /**
  128. * Flush the session data and regenerate the ID.
  129. *
  130. * @return bool
  131. */
  132. public function invalidate();
  133. /**
  134. * Generate a new session identifier.
  135. *
  136. * @param bool $destroy
  137. * @return bool
  138. */
  139. public function regenerate($destroy = false);
  140. /**
  141. * Generate a new session ID for the session.
  142. *
  143. * @param bool $destroy
  144. * @return bool
  145. */
  146. public function migrate($destroy = false);
  147. /**
  148. * Determine if the session has been started.
  149. *
  150. * @return bool
  151. */
  152. public function isStarted();
  153. /**
  154. * Get the previous URL from the session.
  155. *
  156. * @return string|null
  157. */
  158. public function previousUrl();
  159. /**
  160. * Set the "previous" URL in the session.
  161. *
  162. * @param string $url
  163. * @return void
  164. */
  165. public function setPreviousUrl($url);
  166. /**
  167. * Get the session handler instance.
  168. *
  169. * @return \SessionHandlerInterface
  170. */
  171. public function getHandler();
  172. /**
  173. * Determine if the session handler needs a request.
  174. *
  175. * @return bool
  176. */
  177. public function handlerNeedsRequest();
  178. /**
  179. * Set the request on the handler instance.
  180. *
  181. * @param \Illuminate\Http\Request $request
  182. * @return void
  183. */
  184. public function setRequestOnHandler($request);
  185. }