Answer the question
In order to leave comments, you need to log in
How to correctly add cookies to middleware?
Hello.
Add cookies to middleware
public function handle($request, Closure $next)
{
if (!$request->hasCookie('city')) {
return $next($request)->cookie('city', 'testCity');
}
return $next($request);
}
request()->city выдает null
$_COOKIE['city'] выдает testCity
Answer the question
In order to leave comments, you need to log in
Try this:
and add to your method (in brackets) $request Request
or like this:
$request->cookie('city');
use Illuminate\Support\Facades\Cookie;
$value = Cookie::get('name');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question