I am making a redirect to homecontroller after user authenticates and set a auth token to session for use in the home controller as -
Controller 1
$secret = Crypt::encrypt($secret);
Session::put('secret', $secret);
Session::save();
return redirect()->action('loginController@homeRedirect');
Controller 2 -> homeRedirect
function homeRedirect(){
dd(Session::all());
if(Session::has('secret')){
$secret = Session::get('secret');
Session::forget('secret');
Here the dump comes blank array. nothing comes in the session, however if i test this dd(Session::all())
then it gives correct details.
Also I have tried as sending data using with('secret', $secret)
but that is also returning a blank session.
My session.php file has following entry
'driver' => 'file',
and the laravel version is 5.2.
EDIT
Also if I try like this -
function homeRedirect(Request $request){
$ses = $request->session()->get('secret');
dd($ses);
Then I get error stating Session store not set on request.
As you are using Laravel 5.2 , you should make sure you have set route for your
loginController@homeRedirect
in web middleware.Your route should be defined in
routes.php
like soIf it's defined this way:
it won't work