Session does not display correctly in Laravel 10 after AJAX request
P粉295728625
P粉295728625 2023-09-01 15:12:43
0
1
375

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.

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.

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?

https://gist.github.com/realrezamirzaei/3fd51d57a95f90bacd3cc4aec06ba923

"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粉295728625
P粉295728625

reply all (1)
P粉891237912

I understand the problemI 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 usingfruitcake/laravel-corspackage, and considering that I am usingLaravel version 10, there is no need to use this package,Adding it to the core files in the web and api sectionsis enough. Add this:

\Illuminate\Http\Middleware\HandleCors::class
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!