Reputation: 398
I had a controller and in it I am storing a session value like this
if(!Session::isStarted())
Session::start();
}
Session::put('total', $total);
In the view I'm trying to retrieve this value:
if(!Session::isStarted()){
Session::start();
}
var_dump(Session::all()); // <-- value 'total' not showing
This is the output of the session
array(2) { ["_token"]=> string(40) "IzsMtiTOfMpoOzLj53YyMYEMAUHr4mLMnIAWcnaJ" ["flash"]=> array(2) { ["old"]=> array(0) { } ["new"]=> array(0) { } } }
Upvotes: 0
Views: 840
Reputation: 146191
You don't need to use this:
if(!Session::isStarted())
Session::start();
}
The session
will be started by framework, you can simply use this:
Session::put('total', $total);
All you need to configure/set the driver
in app/config/session.php
file and by default Laravel
uses file
driver, it is set in the app/config/session.php
like this:
'driver' => 'file',
Laravel 4 not passing session value from controller to view
Actually you don't need to pass the session, if you set the session
anywhere in your application then it'll be available in anywhere through your application, you can access it from your view
, you don't need to pass it but you have to set/put the value in the session before you access it.
Upvotes: 1