jeudi 25 février 2016

Unable to use session in laravel

I m just creating a simple login page in laravel 5. Problem-: After successfully login i have to create session of email address and move to dashboard. If secession 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 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.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Q3mj1r
via IFTTT

Aucun commentaire:

Enregistrer un commentaire