divHelper11
divHelper11

Reputation: 2208

Laravel session data passing

I don't understand how my data is directed through session using ->with.

For example I am doing a simple redirect with some data:

return Redirect::to('/event')->with('data', 'hello.');

Now, this code below works fine:

$data = Session::get('data');
echo $data; //it says hello

But this one NOT:

var_dump($_SESSION); //empty array

The var_dump gives me empty array, which means that session doesnt contain anything I guess. While the Session::get() has no problems with it. Why does that happen? Please explain it to me a little bit.

Upvotes: 2

Views: 326

Answers (1)

HongKilDong
HongKilDong

Reputation: 1316

For security reasons Laravel uses its own custom session handler which doesn't populate $_SESSION superglobals with your session variables, so to work with laravel session you should only use Session facade's methods

Upvotes: 3

Related Questions