Multiple keys in the session

0

I would like to save and retrieve an array type session in Laravel type in PHP

Example :

PHP :

$_SESSION['dado']['dado1'] = $valor;

Recovering

echo $_SESSION['dado']['dado1'];

Laravel

$request->session()->put(
   [ ['dado']['dado1'] = $valor ]
)

But how would I recover?

So:

echo $request->session()->get(['dado']['dado1'])

?

    
asked by anonymous 25.05.2018 / 19:22

1 answer

1

To create a data in session in the is the following

$value['dado']['dado1'] = "1";
$request->session()->put('key',$value);

or

$value['dado']['dado1'] = "1";
session('key', $value); // armazena a sessão

To recover the session:

$dados = $request->session()->get('key');

or

$dados = session('key')

In other words, the created data must have an identification key so that it can retrieve any information later.

Reference HTTP Session

    
25.05.2018 / 22:48