M
M
Maxim Zolotoy2019-04-22 21:49:15
Laravel
Maxim Zolotoy, 2019-04-22 21:49:15

Why can't I set a cookie in laravel?

I created a middleware class - I wanted to check cookies there and set them. I am using this code. Why do you think that when you refresh the page, NULL stubbornly comes out all the time

namespace App\Http\Middleware;

class CustomerSession
{
    public function handle($request, \Closure $next)
    {
        var_dump(\Cookie::get('customer-session-id'));
        Cookie::queue('customer-session-id', 'test-value', 60 * 24 * 360);
    
        return $next($request);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2019-04-22
@spacenear

Have you read the documentation?
Cookie in exceptions ? If not, is the encryption key set?
Middleware AddQueuedCookiesToResponseworks?
Cookie comes to the browser? Does the browser accept it?
And there are dozens more questions you can ask.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question