Session.php 1.7 KB

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