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.

Session.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OC\Session;
  26. use OCP\ISession;
  27. abstract class Session implements \ArrayAccess, ISession {
  28. /**
  29. * @var bool
  30. */
  31. protected $sessionClosed = false;
  32. /**
  33. * $name serves as a namespace for the session keys
  34. *
  35. * @param string $name
  36. */
  37. abstract public function __construct(string $name);
  38. /**
  39. * @param mixed $offset
  40. * @return bool
  41. */
  42. public function offsetExists($offset): bool {
  43. return $this->exists($offset);
  44. }
  45. /**
  46. * @param mixed $offset
  47. * @return mixed
  48. */
  49. public function offsetGet($offset) {
  50. return $this->get($offset);
  51. }
  52. /**
  53. * @param mixed $offset
  54. * @param mixed $value
  55. */
  56. public function offsetSet($offset, $value) {
  57. $this->set($offset, $value);
  58. }
  59. /**
  60. * @param mixed $offset
  61. */
  62. public function offsetUnset($offset) {
  63. $this->remove($offset);
  64. }
  65. /**
  66. * Close the session and release the lock
  67. */
  68. public function close() {
  69. $this->sessionClosed = true;
  70. }
  71. }