Friday, March 17, 2017

Redirect back when login successful Laravel 5.4

I'm trying to redirect the user to the previous page after login.

In my blade page I've,

@if(Auth::check())
    
@else
    <a href=""> </a> //url to login page
@endif

Before that I'm creating a session so that I can know that the request is from the above blade page.

My controller:

public function log(){
    Session::flash('log_msg', 'login needed!'); 
    return view('my_account');
}

When I put the condition like if(Session::has(log_msg)){//redirect back} in the Login Controller it throws an error.

Now I'm confused where to put the condition. Can anyone tell me where I can put the condition in Logincontroller or in Middelware and how?



via ishan shah

Advertisement