cookie.php 958 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php namespace Laravel\Session\Transporters;
  2. class Cookie implements Transporter {
  3. /**
  4. * The name of the cookie used to store the session ID.
  5. *
  6. * @var string
  7. */
  8. const key = 'laravel_session';
  9. /**
  10. * Get the session identifier for the request.
  11. *
  12. * @param array $config
  13. * @return string
  14. */
  15. public function get($config)
  16. {
  17. return \Laravel\Cookie::get(Cookie::key);
  18. }
  19. /**
  20. * Store the session identifier for the request.
  21. *
  22. * @param string $id
  23. * @param array $config
  24. * @return void
  25. */
  26. public function put($id, $config)
  27. {
  28. // Session cookies may be set to expire on close, which means we will need to
  29. // pass "0" into the cookie manager. This will cause the cookie to not be
  30. // deleted until the user closes their browser.
  31. $minutes = ( ! $config['expire_on_close']) ? $config['lifetime'] : 0;
  32. \Laravel\Cookie::put(Cookie::key, $id, $minutes, $config['path'], $config['domain'], $config['secure']);
  33. }
  34. }