[6.x] Change cookie helper signature to match CookieFactory #31974
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
This changes the
cookie()
helper signature to match theCookieFactory::make
function. These appear to have been mismatched since #23200.Set to 6.x as recommended by @GrahamCampbell in #31970
Problem
I was looking into the below warning we were getting on our frontend SPA in Chrome. I had already set the
secure
config option totrue
inconfig/session.php
. So I decided to investigate why the cookie was not being sent with thesecure
flag as expected.Investigation
The cookie was being returned by using the
response->cookie
method as described in the docs (https://laravel.com/docs/7.x/responses#attaching-cookies-to-responses).After looking into that method I realised it is using the
cookie()
helper function under the hood and this had the$secure = false
as one of its arguments this explained why it was not using the setting specified in thesession.php
config.Workaround
To provide an immediate fix for our application I changed the code to use the
Cookie::make
factory method directly since this does use the configured value as the method signature for that method has$secure = null
. So we changed our response code to this:Fix
Changed
cookie()
helper function signature from$secure = false
to$secure = null
to match theCookieFactory::make
function .