Cookie.php 862 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Cookie-based session class.
  4. *
  5. * @package KO7
  6. * @category Session
  7. *
  8. * @copyright (c) 2007-2016 Kohana Team
  9. * @copyright (c) since 2016 Koseven Team
  10. * @license https://koseven.dev/LICENSE
  11. */
  12. class KO7_Session_Cookie extends Session {
  13. /**
  14. * @param string $id session id
  15. * @return string
  16. */
  17. protected function _read($id = NULL)
  18. {
  19. return Cookie::get($this->_name, NULL);
  20. }
  21. /**
  22. * @return null
  23. */
  24. protected function _regenerate()
  25. {
  26. // Cookie sessions have no id
  27. return NULL;
  28. }
  29. /**
  30. * @return bool
  31. */
  32. protected function _write()
  33. {
  34. return Cookie::set($this->_name, $this->__toString(), $this->_lifetime);
  35. }
  36. /**
  37. * @return bool
  38. */
  39. protected function _restart()
  40. {
  41. return TRUE;
  42. }
  43. /**
  44. * @return bool
  45. */
  46. protected function _destroy()
  47. {
  48. return Cookie::delete($this->_name);
  49. }
  50. }