ISession.php 2.6 KB

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