不在 laravel 5.2 中进行身份验证

Don't working authentication in laravel 5.2

身份验证无效。我手动创建身份验证。
我的 AdminController

class AdminController extends Controller
{

    public function signin() {
        return view('admin.signin');
    }

    public function index(Request $request) {

        dd(Auth::check());
        if (Auth::check())
            return view('admin.index.index', ['login' => Auth::user()->name]);
        else
            return redirect()->action('AdminController@signin');
    }

    public function login() {
        $data = Input::all();

        if (Auth::attempt(['name' => $data['login'], 'password' => $data['password']])) {
            return redirect()->intended('/admin');
        } else {
            return redirect()->intended('/admin/signin');
        }
    }

    public function logout() {
        if (Auth::logout() ) {
            return Redirect::to('/admin');
        }
    }
}  

我的 routes.php 文件:

  //GET
  Route::get('/', 'IndexController@index');
  Route::get('/admin/signin', 'AdminController@signin');
  Route::get('/admin', 'AdminController@index');
  Route::get('/admin/logout', 'AdminController@logout');

  //POST
  Route::post('/admin/auth', 'AdminController@login');   

dd(Auth::check()); 返回 false

我做错了什么?

在 Laravel 5.2 中,您需要使用 web 中间件定义路由以使会话正常工作,因此您的 routes.php 文件应如下所示:

Route::group(['middleware' => ['web']], function () {
  //GET
  Route::get('/', 'IndexController@index');
  Route::get('/admin/signin', 'AdminController@signin');
  Route::get('/admin', 'AdminController@index');
  Route::get('/admin/logout', 'AdminController@logout');

  //POST
  Route::post('/admin/auth', 'AdminController@login');
});