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