1: <?php namespace Laravel\Session\Drivers; use Laravel\Crypter, Laravel\Cookie as C;
2:
3: class Cookie extends Driver {
4:
5: /**
6: * The name of the cookie used to store the session payload.
7: *
8: * @var string
9: */
10: const payload = 'session_payload';
11:
12: /**
13: * Load a session from storage by a given ID.
14: *
15: * If no session is found for the ID, null will be returned.
16: *
17: * @param string $id
18: * @return array
19: */
20: public function load($id)
21: {
22: if (C::has(Cookie::payload))
23: {
24: return unserialize(Crypter::decrypt(C::get(Cookie::payload)));
25: }
26: }
27:
28: /**
29: * Save a given session to storage.
30: *
31: * @param array $session
32: * @param array $config
33: * @param bool $exists
34: * @return void
35: */
36: public function save($session, $config, $exists)
37: {
38: extract($config, EXTR_SKIP);
39:
40: $payload = Crypter::encrypt(serialize($session));
41:
42: C::put(Cookie::payload, $payload, $lifetime, $path, $domain, $secure);
43: }
44:
45: /**
46: * Delete a session from storage by a given ID.
47: *
48: * @param string $id
49: * @return void
50: */
51: public function delete($id)
52: {
53: C::forget(Cookie::payload);
54: }
55:
56: }
57: