Cookie.php 840 B

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