Replies: 9 comments
-
|
Can you please share how are you setting the session cookie? This issue will be converted to discussion or closed due to version 10 not being supported. But I want to fix this if possible in v10. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for looking into this. I am not manually setting any cookies at all — I’m using Laravel’s default behavior. I’ve noticed that Laravel attempts to send session/cookie headers on every request by default (e.g., session cookie, CSRF cookie), but in my case those headers do not appear unless php artisan optimize has been run. Also, when I return a plain array from a controller, Laravel does not automatically set the response as application/json and instead the browser treats it as text/html. So: |
Beta Was this translation helpful? Give feedback.
-
|
Controllers must return Responces or Views not arrays. On Json response no cookie should be sent. Cookies are for view responses from web.php not for json responses from api.php. |
Beta Was this translation helpful? Give feedback.
-
|
We are observing this issue even with a very minimal setup. However, without running This makes Route::get('/debug', function () {
return [
'success' => true,
'message' => 'Debug',
];
}); |
Beta Was this translation helpful? Give feedback.
-
|
Ok. This is a diferent issue. |
Beta Was this translation helpful? Give feedback.
-
|
Coming back to your first issue. Can you try php artisan config:cache instead of optimize and confirm the issue persists? |
Beta Was this translation helpful? Give feedback.
-
|
@yudhees I cannot reproduce the issue. Please check a sample repository at: https://github.com/rodrigopedra/issue-58193 The Readme file has installation and usage instructions. |
Beta Was this translation helpful? Give feedback.
-
|
@rodrigopedra @marius-ciclistu Yes, that's the issue not getting from local and also other Laravel projects even the same project in QA version issue getting on dev version server only once i run "php artisan optimzie" issue gone and will get cookie with laravel default headers event i hosted on another ec2 instance getting same |
Beta Was this translation helpful? Give feedback.
-
|
It seems to be some configuration specific to your project. Just to reiterate, the repository I linked above has the code for Laravel 10. Also, both the route returning an array work as expected (converting the array to JSON), and the cookies are sent as expected, without the need to run any additional command such as If we cannot replicate the issue locally, it is almost impossible to offer help. I would check for any packages or configurations that depend on the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
10
PHP Version
8.2
Database Driver & Version
No response
Description
Expected behavior
Laravel should send cookies even without running
optimize.Observed behavior
Cookies are not present until
php artisan optimizeis run.Notes
This only happens in a production; local dev does not reproduce.
Steps To Reproduce
php artisan optimizeSet-CookieheaderBeta Was this translation helpful? Give feedback.
All reactions