I'm just creating a simple login page in Laravel 5. Problem: After successfully login I have to create a session of email address and move to dashboard. If session is not created than move to login page.
Here is my controller function code:
public function admin_auth()
{
$matchThese = ['email' => $_POST['email'], 'password' => $_POST['password']];
$login['result'] = DB::table('login_auth')->where($matchThese)->get();
if($login['result'])
{
//session_start();
date_default_timezone_set('Asia/Kolkata');
$_SESSION['session_email'] = $_POST['email'];
Session::put('session_email', $_POST['email']);
if (Session::has('session_email'))
{
echo 'Done';
}else echo 'Session Not Created';
}else echo 'Email Or Password Not Match';
}
In above function I got 'Done'.It means the session is created but when I'm checking same variable in other method of the same controller then session is not set.
Here is my other function:
public function dashboard()
{
if (Session::has('session_email'))
{
return view('login.dashboard');
}else echo 'Session Not Created';
}
I always got 'Session Not Created'.
Thanks for help in advancd.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire