作者:哒Dayling玲 | 来源:互联网 | 2023-09-18 12:29
HowcanIsetacookiewithajsonresponse?如何设置带有json响应的cookie?Inoticed,formeatleast,thef
How can I set a COOKIE with a json response?
如何设置带有json响应的COOKIE?
I noticed, for me at least, the following command is the only thing working that sets a COOKIE:
我注意到,至少对我来说,以下命令是设置COOKIE的唯一工作:
return Redirect::to('/')
->withCOOKIE(COOKIE::make('blog', $COOKIE_values, 1000));
Of course if it was an ajax request it would return the target of the redirect.
当然,如果是ajax请求,它将返回重定向的目标。
How could I translate this to an ajax request and return a json response with the COOKIE?
我怎么能将它转换为ajax请求并返回带有COOKIE的json响应?
2 个解决方案