php - how to make a session in laravel? -


i want create session based on $id (unique id). when each user enters web app have own session id , own array. when put in function , every time enter function session not being stored , overriding previous session. how modify code session created each user in function test().

here code:

public function test() {     $id = 'new3'; //later on auto generate id     $array[$id] = ['one' => 'abc', 'two' => 'def'];      if (!session($id)) {         session($array);     }      dd(session()->all()); } 

you should manipulate laravel session this:

public function test(request $request) {     $id = 'new3'; //later on auto generate id     $array[$id] = ['one' => 'abc', 'two' => 'def'];  // determining if item exists in session. if (!$request->session()->has($id)) {     // storing data in session.     $request->session()->put($id, $array[$id]); }      dd($request->session()->all()); } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -