Home  >  Q&A  >  body text

laravel - How long does the message returned by redirect()->with('message','') last in the session?

Code in the controller:
return redirect('reviewmessage')->with('message', array('type' => 'success','content'=>'Message successful! You can view other people's or your previous messages. '));
Route 'reviewmessage' returns the view 'reviewmessage',
I add it to the view
@if (Session::has('message') )

        <p class="alert alert-success" >
            <p>{{ Session::get('message')['content'] }}</p>
        </p>

@endif
After the operation is successful, the content in the message will be returned.
My question is how long will this session['message'] be saved?
After I refresh the page, this prompt will disappear, that is, it will only survive the current request?
How to make it exist for a long time?

PHP中文网PHP中文网2713 days ago678

reply all(1)I'll reply

  • 迷茫

    迷茫2017-05-16 16:57:34

    通常重定向至新的 URL 时会一并将数据存进一次性 Session相当于Session::flash('message', 'value');
    想长期存在Session::put('message', 'value');

    reply
    0
  • Cancelreply