jeudi 28 janvier 2016

Auth::user() is null after user Creation :: Laravel 5.2

I have a Route like below.

Route::group(['middleware' => ['web', 'auth']], function() {
   Route::get('/My', array('uses' => 'AccountController@MyAccount', 'as' => 'Profile')); 
});

We have a file with the name of RegisterUser.php at this Path:

\vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php

After creating the user, redirecting user to a below Url

http://localhost/public/My

My code is like below.

public function register(RegisterRequest $request)
{
    Auth::guard($this->getGuard())->login($this->create($request->all()));
    //print_r(Auth::user());//Auth::user() is Not Null here
    //die();
    return \Redirect()->route('Profile');
}

but this always send user to Login Page. I also checked in Controller Action and Auth::user() is null

public function MyAccount() {
    echo '<pre>';
    print_r(\Auth::user()); //It shows null value
    echo '</pre>';
    die();
    return View("Account.Profile");
}

Am I missing something ?



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

Aucun commentaire:

Enregistrer un commentaire