Laravel 5.2 Session flash not working even with web middleware

后端 未结 6 1479
孤城傲影
孤城傲影 2020-12-29 15:25

I am trying to implement flash messaging using sessions but am unable to do so.

In my controller I have:

public function store(Request $request) {
          


        
6条回答
  •  自闭症患者
    2020-12-29 16:10

    I use the following:

    In my controller:

    public function xyz(){
       // code
    
       // This
       return redirect()->action('homeController@index')->with('success', 'Check! Everything done!');
    
        // Or this
        return redirect('/index')->with('success', 'Check! Everything done!');
    }
    

    In my view:

    @if(session('success'))
        {{ session('success') }}
    @endif
    

    Nothing else. The web-middleware is assigned to every route.

提交回复
热议问题