【问题标题】:Laravel 5.2 session flash working on localhost but not working on server?Laravel 5.2 session flash 在本地主机上工作但在服务器上不工作?
【发布时间】:2017-02-17 05:48:34
【问题描述】:

Session flash 在本地工作正常,但在 Laravel 5.2 的服务器上不能工作?

在控制器中:

Session::flash('key', value");
return Redirect::to('/');

在视图中:

@if (Session::has('key') && Session::get('key')!='') 

alert('.......');

@endif

【问题讨论】:

  • 确保在config/session.php.env 上配置了正确的驱动程序
  • 什么是 'domain' => config/session.php 中的 null

标签: laravel-4 laravel-5 laravel-5.2 laravel-5.1 laravel-routing


【解决方案1】:

阅读:https://laravel.com/docs/5.2/responses#redirecting-with-flashed-session-data

Route::post('user/profile', function () {
    // Update the user's profile...

    return redirect('dashboard')->with('status', 'Profile updated!');
});

在视图/刀片中

@if (session('status'))
    <div class="alert alert-success">
        {{ session('status') }}
    </div>
@endif

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-04
    • 2014-01-15
    • 1970-01-01
    • 2015-04-09
    • 2016-02-21
    相关资源
    最近更新 更多