You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ISession.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. * @author Thomas Tanghus <thomas@tanghus.net>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. /**
  29. * Public interface of ownCloud for apps to use.
  30. * Session interface
  31. *
  32. */
  33. // use OCP namespace for all classes that are considered public.
  34. // This means that they should be used by apps instead of the internal ownCloud classes
  35. namespace OCP;
  36. use OCP\Session\Exceptions\SessionNotAvailableException;
  37. /**
  38. * Interface ISession
  39. *
  40. * wrap PHP's internal session handling into the ISession interface
  41. * @since 6.0.0
  42. */
  43. interface ISession {
  44. /**
  45. * Set a value in the session
  46. *
  47. * @param string $key
  48. * @param mixed $value
  49. * @since 6.0.0
  50. */
  51. public function set(string $key, $value);
  52. /**
  53. * Get a value from the session
  54. *
  55. * @param string $key
  56. * @return mixed should return null if $key does not exist
  57. * @since 6.0.0
  58. */
  59. public function get(string $key);
  60. /**
  61. * Check if a named key exists in the session
  62. *
  63. * @param string $key
  64. * @return bool
  65. * @since 6.0.0
  66. */
  67. public function exists(string $key): bool;
  68. /**
  69. * Remove a $key/$value pair from the session
  70. *
  71. * @param string $key
  72. * @since 6.0.0
  73. */
  74. public function remove(string $key);
  75. /**
  76. * Reset and recreate the session
  77. * @since 6.0.0
  78. */
  79. public function clear();
  80. /**
  81. * Close the session and release the lock
  82. * @since 7.0.0
  83. */
  84. public function close();
  85. /**
  86. * Wrapper around session_regenerate_id
  87. *
  88. * @param bool $deleteOldSession Whether to delete the old associated session file or not.
  89. * @param bool $updateToken Wheater to update the associated auth token
  90. * @return void
  91. * @since 9.0.0, $updateToken added in 14.0.0
  92. */
  93. public function regenerateId(bool $deleteOldSession = true, bool $updateToken = false);
  94. /**
  95. * Wrapper around session_id
  96. *
  97. * @return string
  98. * @throws SessionNotAvailableException
  99. * @since 9.1.0
  100. */
  101. public function getId(): string;
  102. }