Session does not display correctly in Laravel 10 after AJAX request
P粉295728625
2023-09-01 15:12:43
<p>I am developing a web application using Laravel framework. I'm using the Laravel session system in part of my application and configured it to store sessions in a database. </p>
<p>My problem is that the session set in one of the routes in the application does not display correctly in other pages and instead returns a null value. I should mention that this problem only occurs when I send a request to the server via AJAX and update the session. </p>
<p>I have checked all session configuration settings as well as php.ini and .env settings, but the problem persists. Do you have any ideas to solve this problem? </p>
<p>https://gist.github.com/realrezamirzaei/3fd51d57a95f90bacd3cc4aec06ba923</p>
<p>"I'm trying to configure Laravel sessions to store sessions in the database, and I've checked the session settings in the php.ini and .env files. However, the session set in one of the routes in my application doesn't The display displays correctly in other pages, but a null value is returned. I want the session to display correctly on all pages."</p>
I understand the problem I have a problem when I want to request from another domain to the main site. But I realized that this problem can be solved by using fruitcake/laravel-cors package, and considering that I am using Laravel version 10, there is no need to use this package, Adding it to the core files in the web and api sections is enough. Add this: