Laravel - How to store array in session?
<p>I am trying to store the $user array in session but only id is stored in session. How can I put the first_name and last_name also ?</p>

<pre><code>public function getIndex( Request $request )
{
    $this-&gt;data['firstNames'] = \DB::table('tb_users')-&gt;orderBy('first_name')-&gt;lists('first_name', 'id');
    $user = User::where('id', '=', $request-&gt;get('id'))-&gt;get()-&gt;toArray();
    Session::put('user', [ 'id' =&gt; $request-&gt;get('id'), 'last_name' =&gt; $request-&gt;get('last_name'), 'first_name' =&gt; $request-&gt;get('first_name'), ]);
    return view('dashboard.index',$this-&gt;data)-&gt;with('user', $user);
}
</code></pre>

<p>This is the select form</p>

<pre><code>&lt;form action="" method="post"&gt;
{!! Form::select('id', $firstNames) !!}
&lt;button type="submit" value="Submit"&gt;Go&lt;/button&gt;
&lt;/form&gt;
</code></pre>