Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jordiglezllinas's avatar

Reload laravel session data by jquery

Hi guys,

I am looking for some help. I would like to reload the Laravel session data after a success ajax request. I am trying to show the new session data using a bootstrap modal.

Any ideas??

Thanks a lot.

0 likes
5 replies
Ozan's avatar
Ozan
Best Answer
Level 32

return the session data within the success function of AJAX?

Controller:

return response([
    'sessionData' => session()->all()
]);

View:

<script type="text/javascript">
    $.ajax({
        url: '/path/to/file',
        type: 'default GET (Other values: POST)',
        data: {},
        success: function (result) {
            // use it here
            sessionData = result.sessionData
        }
    });
</script>
1 like
jordiglezllinas's avatar

Thanks for the answer. I was looking for a function to reload session data (grrrrr). Pass a variable with the data will be fine. ;)

Please or to participate in this conversation.