ISession.php 2.7 KB

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