Key keys in session

Asked

Viewed 50 times

0

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

Example:

in the PHP:

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

Recovering

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

In the Laravel I’m trying like this:

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

But how would I recover?

Thus:

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

?

  • The @adventistaam solution did not work?

  • I don’t know why, but this section affects another system

  • Look your question is another! wondered how to create the session. The problem of sharing the same session is because it must be running on a test server! already seen that the main hosting service is configured correctly.

  • Even on different systems one session affects all?

  • Following your question: "I would like to save and recover an array type session in Laravel type in PHP" this has been answered. Then you opened another question is there you should worry about that doubt is how it works... !!! understood. https://answall.com/questions/301978/sess%C3%A3o-Laravel-n%C3%A3o-storages

1 answer

1


To create a die in session in the is as follows

$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')

That is, the data created needs to have an identification key so that it can recover any information.

Reference: HTTP Session

Browser other questions tagged

You are not signed in. Login or sign up in order to post.