cookie.php 909 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php namespace Laravel\Session\Transporters;
  2. class Cookie implements Transporter {
  3. /**
  4. * The cookie manager instance.
  5. *
  6. * @var Cookie
  7. */
  8. protected $cookies;
  9. /**
  10. * Create a new cookie session transporter instance.
  11. *
  12. * @param Cookie $cookie
  13. * @return void
  14. */
  15. public function __construct(\Laravel\Cookie $cookies)
  16. {
  17. $this->cookies = $cookies;
  18. }
  19. /**
  20. * Get the session identifier for the request.
  21. *
  22. * @param array $config
  23. * @return string
  24. */
  25. public function get($config)
  26. {
  27. return $this->cookies->get('laravel_session');
  28. }
  29. /**
  30. * Store the session identifier for the request.
  31. *
  32. * @param string $id
  33. * @param array $config
  34. * @return void
  35. */
  36. public function put($id, $config)
  37. {
  38. $minutes = ($config['expire_on_close']) ? 0 : $config['lifetime'];
  39. $this->cookies->put('laravel_session', $id, $minutes, $config['path'], $config['domain']);
  40. }
  41. }