Laravel 5.4 - Cookie队列

Chr*_*ian 3 cookies laravel dingo-api

我正在使用Laravel 5.4,我写了类似的东西:

     Cookie::queue(
        'refresh_token',
        $data->refresh_token,
        864000, // 10 days
        null,
        null,
        false,
        true // HttpOnly
    );

    return response('hello world');
Run Code Online (Sandbox Code Playgroud)

返回的响应不包含refresh_token cookie return response('hello world')->withCookie(...).

Laravel 5.4文档不再像5.0 doc那样声明排队cookie.这是否意味着在5.4版本中删除了该功能,或者我的代码中出错?

为了完整起见,我使用的是Dingo API包,并且响应是精心设计的.

谢谢您的帮助.

Chr*_*ian 23

我找到:

没有为api请求启用Cookie排队,这就是它无效的原因.

我不得不在相应文件的中间件部分添加:

\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,

适当的文件是App/Http/Kernel.php(使用Laravel API)或App/Config/api.php