【问题标题】:Laravel 5.1 Auth not working on server while on local environment its doing right jobLaravel 5.1 Auth 在本地环境中无法在服务器上工作
【发布时间】:2016-10-20 09:55:15
【问题描述】:

Laravel 5.1.35 身份验证在服务器上部署后不起作用。在本地环境中,它工作正常。

默认成功登录重定向到“/home”,并且在/home rout 处理程序中 Auth::check() 返回 false。

Route::get( '/home', function () {
  var_dump(Auth::user()); 
} );

上面的代码打印 bool(false);

路线代码:

Route::get('/logout', 'Auth\AuthController@getLogout');
Route::get('/login', 'Auth\AuthController@getLogin');
Route::get( '/home', function () {
  var_dump(Auth::user());
} );

Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('/login/{param}', 'Auth\AuthController@getLogin');
Route::get('/register', 'Auth\AuthController@getRegister');
Route::get('/signup', 'Auth\AuthController@getLogin');
Route::post('/auth/stepOne', 'Auth\AuthController@stepOne');
Route::post('/auth/stepTwo', 'Auth\AuthController@stepTwo');
Route::post('/auth/stepTwoBrand', 'Auth\AuthController@stepTwoBrand');
Route::post('/auth/register', 'Auth\AuthController@postRegister');

【问题讨论】:

    标签: laravel-5.1 laravel-authorization


    【解决方案1】:

    实际问题是 php 开始标记前有一个空行。

    我使用以下核心 php 函数进行重定向,而不是从控制器返回视图文件或使用 laravel Riderect。

    header('Location: /');
    

    它打印了有空行的实际文件。删除此行解决了我的问题。

    我的代码库中有数千个文件。我的假设是我尝试了不同的脚本来在任何文件的开头找到这样的空行,并且根据这些脚本结果没有这样的文件。我假设我的任何文件中都没有空行。但是 header('Location: /') 证明我的假设没有错,而且我在错误的行上工作。

    【讨论】:

      猜你喜欢
      • 2019-03-16
      • 2019-05-05
      • 2020-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-21
      • 2018-12-19
      • 2021-12-28
      相关资源
      最近更新 更多