Certainly! Here’s a solution and explanation for the issue:
Explanation:
In Laravel 12.26.0 and higher, the global cookie() helper function has changed. It now returns null if you pass a domain that contains a scheme (like https://). The domain parameter should only be the domain name (e.g., example.com), not the full URL.
Passing a full URL (with https://) will cause the function to return null because Laravel cannot set a cookie for a domain with a scheme.
Solution:
Update your code to only pass the domain name, not the full URL. For example:
dump(cookie('foo', 'bar', 3600, '/', 'example.com', false, false));
Key Points:
- The 5th parameter should be just the domain (e.g.,
'example.com'), not'https://example.com'. - If you want the cookie to be available on all subdomains, you can use
'.example.com'.
Reference: See Laravel's cookie helper documentation for more details.
Summary:
Remove the https:// from the domain parameter, and the cookie() helper will return a valid cookie object instead of null.