Laravel Cookie

With Response

return response('Hello World')->cookie(
    'name', 'value', $minutes

With view

use Illuminate\Support\Facades\Cookie;

$minutes = 60 * 24 * 365 * 1;// 1 year
$cookie = Cookie::queue('branch_id', $branch_id, $minutes);

return view('admin.category.index', $data);
// or return redirect('/admin/category');

20200305 Update
Laravel Cookie always return NULL after redirection for unknown reason. Native php cookie should be a better solution

setcookie('site', $site, time() + 60*60*24*30);


Important Comemnt:

Cookies are only returned to the browser at the end of the request, so you can never set and read the cookie in the same request cycle.

I suggest if you find the cookie set then you read it and add it to the session. If not then you set the cookie, and also add it to the session. Then, wherever you would have used the cookie, you use the session instead.