Hello,
I am implementing a login authentication module for my application using laravel 5.
routes.php
// creating a route for login
Route::get('login','LoginController@index');
Route::post('login','LoginController@authUserPass');
I have a model Login.php in which I have the following code for authentication
public function authUserPass(CreateLoginRequest $request)
{
$checkUser = Login::where('email',$request->email)->get();
if (!$checkUser->isEmpty()){
Session::put('email',$request->email); //Update
return view('login.dashboard');
}
else{
return "error";
}
}
Now I want to start the session for the user and redirect him to the dashboard view(Redirection works fine).I need help with sessions and calling session objects.
Update:I added the user email in session here and I was able to get it on dashboard,but is the approach correct?
For example:
When I redirect view('dash.blade.php') how can I create and access the session variables there? so that I can fetch the user info on dashboard.
Also I would like comments on, if the above code for authentication is the right way to go as I also have to use it as an API for mobile app