正如标题所暗示的,
这是代码...
public function index(Request $request, Application $app)
{
$cookies = $request->cookies;
print_r($request->cookies);
if(!$cookies->has("recordsPerPage"))
{
$response = new Response();
$cookie = new Cookie("recordsPerPage", $app['defaultRecordsPerPage']);
$response->headers->setCookie($cookie);
}
print_r($request->cookies);exit; //prints nothing here !!
}
我也尝试将其设置为$app->after()
但失败了。除了在控制器中设置 cookie 之外,您还有其他方法吗?
谢谢你。