Laravel:要查看的会话数据 [英] Laravel : Session data to view

查看:66
本文介绍了Laravel:要查看的会话数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,我正在其中检查错误.

I have the following code, In which i am checking for error.

<div class="alert alert-danger {{ (\Session::has('message') && \Session::get('form', 'login') == 'login') ? '' : 'display-hide' }}">
    <button class="close" data-close="alert"></button>
    <span>
        {!! \Session::has('message') ? \Session::get('message') : 'Please correct your fields.' !!}
    </span>
</div>

在控制器方面,我有:

return redirect()
        ->back()
        ->with('message', 'Incorrect email or password.')
        ->with('form', 'login')
        ->withInput(\Input::except('password'));

问题在于消息未显示在那里.

The thing is that the message is not showing there.

页面刷新并且没有消息出现.

Just the page refreshes and no message comes up.

有什么主意吗?我想念什么吗?

Any idea ? Am i missing something ?

推荐答案

仅在您的视图上使用\Session::pull('message')而不是\Session::get('message').

Simply on your view use \Session::pull('message') instead of \Session::get('message').

就这么简单.

这篇关于Laravel:要查看的会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆