1 | <?php |
||
35 | class Cookie |
||
36 | { |
||
37 | /** |
||
38 | * How long is forever (in minutes)? |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | const FOREVER = 2628000; |
||
43 | |||
44 | /** |
||
45 | * The cookies that have been set. |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | public static $jar = array(); |
||
50 | |||
51 | /** |
||
52 | * Determine if a cookie exists. |
||
53 | * |
||
54 | * @param string $name |
||
55 | * |
||
56 | * @return bool |
||
57 | */ |
||
58 | public static function has($name) |
||
62 | |||
63 | /** |
||
64 | * Get the value of a cookie. |
||
65 | * |
||
66 | * @param $name |
||
67 | * @param null $default |
||
68 | * |
||
69 | * @return null|string |
||
70 | */ |
||
71 | public static function get($name, $default = null) |
||
85 | |||
86 | /** |
||
87 | * Set the value of a cookie. |
||
88 | * |
||
89 | * @param $name |
||
90 | * @param $value |
||
91 | * @param int $expiration |
||
92 | * @param string $path |
||
93 | * @param null $domain |
||
94 | * @param bool $secure |
||
95 | * |
||
96 | * @return bool |
||
97 | * @throws \RuntimeException |
||
98 | */ |
||
99 | public static function put($name, $value, $expiration = 0, $path = '/', $domain = null, $secure = false) |
||
116 | |||
117 | /** |
||
118 | * Set a "permanent" cookie. The cookie will last for one year. |
||
119 | * |
||
120 | * @param $name |
||
121 | * @param $value |
||
122 | * @param string $path |
||
123 | * @param null $domain |
||
124 | * @param bool $secure |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | public static function forever($name, $value, $path = '/', $domain = null, $secure = false) |
||
132 | |||
133 | /** |
||
134 | * Delete a cookie. |
||
135 | * |
||
136 | * @param string $name |
||
137 | * @param string $path |
||
138 | * @param null $domain |
||
139 | * @param bool $secure |
||
140 | * |
||
141 | * @return bool |
||
142 | */ |
||
143 | public static function forget($name, $path = '/', $domain = null, $secure = false) |
||
147 | |||
148 | /** |
||
149 | * Hash the given cookie value. |
||
150 | * |
||
151 | * @param string $value |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | public static function hash($value) |
||
159 | |||
160 | /** |
||
161 | * Parse a hash fingerprinted cookie value. |
||
162 | * |
||
163 | * @param string $value |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | protected static function parse($value) |
||
185 | |||
186 | /** |
||
187 | * Send along with the rest of the HTTP headers. |
||
188 | */ |
||
189 | public static function send() |
||
196 | } |
||
197 |