File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -338,14 +338,26 @@ public static function files($filenames = null)
338338 * This method returns a key-value array of Cookie data sent in the HTTP request, or
339339 * the value of an array key if requested. If the array key does not exist, NULL is returned.
340340 *
341- * @param string|null $key
341+ * @param string|array| null $key A cookie name, a list of cookie names, or null for all cookies
342342 * @return array|string|null
343343 */
344- public static function cookies (? string $ key = null )
344+ public static function cookies ($ key = null )
345345 {
346- return $ key === null ?
347- Cookie::all () :
348- Cookie::get ($ key );
346+ if ($ key === null ) {
347+ return Cookie::all ();
348+ }
349+
350+ if (is_array ($ key )) {
351+ $ cookies = [];
352+
353+ foreach ($ key as $ name ) {
354+ $ cookies [$ name ] = Cookie::get ($ name );
355+ }
356+
357+ return $ cookies ;
358+ }
359+
360+ return Cookie::get ($ key );
349361 }
350362
351363 /**
@@ -356,7 +368,7 @@ public static function cookies(?string $key = null)
356368 */
357369 public static function flash (?string $ key = null )
358370 {
359- return \Leaf \Flash::display ($ key );
371+ return \Leaf \Flash::display ($ key ?? ' default ' );
360372 }
361373
362374 /**
You can’t perform that action at this time.
0 commit comments