Laravel 使用 Cookie 有兩種方式
設定 Cookie
// 使用 Cookie::make 並設定時間
$cookie = Cookie::make('name', 'Johnson', $minutes);
// Forever
$cookie = Cookie::forever('name', 'Johnson');
// 使用 make 或 forever 產生的 Cookie 必須自行Attaching,這樣才算設定完成。
// return Response::make('Hello World')->withCookie($cookie);
return Redirect::to('test2')->withCookie($cookie);
另一種做法,使用 queue 就不需要 Attaching
Cookie::queue('name', 'Johnson', $minutes);
return Redirect::to('test2');