Session.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. * Get the current session ID.
  13. *
  14. * @return string
  15. */
  16. public function getId();
  17. /**
  18. * Set the session ID.
  19. *
  20. * @param string $id
  21. * @return void
  22. */
  23. public function setId($id);
  24. /**
  25. * Start the session, reading the data from a handler.
  26. *
  27. * @return bool
  28. */
  29. public function start();
  30. /**
  31. * Save the session data to storage.
  32. *
  33. * @return bool
  34. */
  35. public function save();
  36. /**
  37. * Get all of the session data.
  38. *
  39. * @return array
  40. */
  41. public function all();
  42. /**
  43. * Checks if a key exists.
  44. *
  45. * @param string|array $key
  46. * @return bool
  47. */
  48. public function exists($key);
  49. /**
  50. * Checks if an a key is present and not null.
  51. *
  52. * @param string|array $key
  53. * @return bool
  54. */
  55. public function has($key);
  56. /**
  57. * Get an item from the session.
  58. *
  59. * @param string $key
  60. * @param mixed $default
  61. * @return mixed
  62. */
  63. public function get($key, $default = null);
  64. /**
  65. * Put a key / value pair or array of key / value pairs in the session.
  66. *
  67. * @param string|array $key
  68. * @param mixed $value
  69. * @return void
  70. */
  71. public function put($key, $value = null);
  72. /**
  73. * Get the CSRF token value.
  74. *
  75. * @return string
  76. */
  77. public function token();
  78. /**
  79. * Remove an item from the session, returning its value.
  80. *
  81. * @param string $key
  82. * @return mixed
  83. */
  84. public function remove($key);
  85. /**
  86. * Remove one or many items from the session.
  87. *
  88. * @param string|array $keys
  89. * @return void
  90. */
  91. public function forget($keys);
  92. /**
  93. * Remove all of the items from the session.
  94. *
  95. * @return void
  96. */
  97. public function flush();
  98. /**
  99. * Generate a new session ID for the session.
  100. *
  101. * @param bool $destroy
  102. * @return bool
  103. */
  104. public function migrate($destroy = false);
  105. /**
  106. * Determine if the session has been started.
  107. *
  108. * @return bool
  109. */
  110. public function isStarted();
  111. /**
  112. * Get the previous URL from the session.
  113. *
  114. * @return string|null
  115. */
  116. public function previousUrl();
  117. /**
  118. * Set the "previous" URL in the session.
  119. *
  120. * @param string $url
  121. * @return void
  122. */
  123. public function setPreviousUrl($url);
  124. /**
  125. * Get the session handler instance.
  126. *
  127. * @return \SessionHandlerInterface
  128. */
  129. public function getHandler();
  130. /**
  131. * Determine if the session handler needs a request.
  132. *
  133. * @return bool
  134. */
  135. public function handlerNeedsRequest();
  136. /**
  137. * Set the request on the handler instance.
  138. *
  139. * @param \Illuminate\Http\Request $request
  140. * @return void
  141. */
  142. public function setRequestOnHandler($request);
  143. }