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

Moenchfracht's avatar

Session push data array

Hello, I have an array 'companydetails' with some values in it stored in my session. I want to add all request inputs using: \Session::push('companydetails', request()->all()); but this adds a new array to the existing one. Here's the output:

  "companydetails" => array:7 [▼
    "name" => "test 123"
    "address" => "addr 123"
    "zip" => "1010"
    "city" => "v"
    "phone" => "12341234"
    "title" => null
    0 => array:1 [▼
      "submit_county" => "1"
    ]
  ]

I want to add the "submit_county" value to the companydetails without the [0] Thanks for help!

0 likes
1 reply
Moenchfracht's avatar

I found a workaround using:

foreach (request()->except('_token') as $key => $value) {
            \Session::put('companydetails.'.$key, $value);
        }

But there must be an easier way - or??

Please or to participate in this conversation.