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

girishsasidharan's avatar

Laravel 5.1 Session is not storing all data

$clickarray = array();

    if (Session::has('list_' . $ward)) {

        $click_selectedking_id = Session::get('list_' . $ward);

        $key = array_search($click_id, $click_selectedking_id);

        if ($key === FALSE) {

            array_push($click_selectedking_id, $click_id);

            $clickarray = $click_selectedking_id;

        } else {

            unset($click_selectedking_id[$key]);

            $clickarray = $click_selectedking_id;

        }

    } else {

        array_push($clickarray, $click_id);

    }

    Session::put('list_' . $ward, $clickarray);

    Session::save();

    return $clickarray;

I am storing an array in session. Purpose is to highlight selected table row after page refresh. Using an ajax request to this function with a key to store in the session. Sometimes Session is not keeping the last value passed.

Session::put('list_' . $ward, $clickarray);

    Session::save();

    return Session::get('list_' . $ward);

I am getting the data here. But not getting on the next request. Missing last value pass to this function. I feel there is something wrong with session.

0 likes
0 replies

Please or to participate in this conversation.