[6.x] Change cookie helper signature to match CookieFactory - #31974
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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::makefunction. 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
secureconfig option totrueinconfig/session.php. So I decided to investigate why the cookie was not being sent with thesecureflag as expected.Investigation
The cookie was being returned by using the
response->cookiemethod 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 = falseas one of its arguments this explained why it was not using the setting specified in thesession.phpconfig.Workaround
To provide an immediate fix for our application I changed the code to use the
Cookie::makefactory 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 = falseto$secure = nullto match theCookieFactory::makefunction .