Laravel 5.2 Auth不会坚持其他路线

时间:2016-08-30 08:06:29

标签: laravel laravel-5.2

我是Laravel的新手。我正在创建的Laravel应用程序在我的本地计算机上完美运行,但当我将其上传到我的主机上时,Auth会话不会在其他路由上持续存在。

routes.php文件

Route::group([], function () {
        Route::group(['domain' => 'admin.domain.com'], function() {
                 Route::get('/login', 'LoginController@login');
                 Route::get('/checklogin', 'CheckLoginController@check');
        });
});

LoginController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests;
use App\User as User;

class LoginController extends Controller
{
    //
    public function login()
    {
        $user = User::find(1);
        Auth::login($user);
        return "logged in"; //returns logged in
    }   
}

CheckLoginController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Http\Requests;

class CheckLoginController extends Controller
{
    //
    public function check()
    {
        if( !Auth::guest() ) :
            echo "logged in";
        else :
            echo "Not logged in"; //returns this
        endif;
    }   
}

0 个答案:

没有答案