Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
70 views
in Technique[技术] by (71.8m points)

How to fixed issue whiule creating cookie in laravel?

I am using Laravel 8 my cookie function not create cookie in browser. My code is

public function connectWoocommerce(Request $request)
{
    Cookie::queue('site_url', $request->site_url, time() + (10 * 365 * 24 * 60 * 60));
    Cookie::queue('key', $request->consumer_key, time() + (10 * 365 * 24 * 60 * 60));
    Cookie::queue('secret', $request->consumer_secret, time() + (10 * 365 * 24 * 60 * 60));
    dd($request->all());
}

How can solve it thanks.

question from:https://stackoverflow.com/questions/65896605/how-to-fixed-issue-whiule-creating-cookie-in-laravel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

IlluminateCookieMiddlewareAddQueuedCookiesToResponse::class middleware is responsible for setting queued cookies to the response. Make sure to have it in you $middleware list.

It will not be called if you terminate the script from anywhere within your controller.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...