首页 > 解决方案 > Laravel 419 页面在表单提交时过期

问题描述

在 Laravel 8 中,我得到一个 419 | 每当我尝试提交表单时出现页面过期错误。我确保使用 Blade Directive @csrf 包含 CSRF 令牌。为了调试简单,我将表单简化为:

<form id="form-contact" name="form-contact" class="contact-form" method="POST">
    @csrf

    <div class="row"> 
        <div class="col-sm-6 animated">
            <div class="input-text form-group">
                <input type="text" name="name" id="name" class="input-name form-control" placeholder="Full Name*" />
            </div>
        </div>
    </div>
    <button class="btn btn-sm active" type="submit">Submit</button>
</form>

而且我仍然收到 419 页面过期错误。

在我的 .env 文件中:

SESSION_DRIVER=file
SESSION_LIFETIME=120

在命令行上,如果我检查我的会话文件夹权限:

ls -ld storage/framework/sessions

我得到:

drwxrwsr-x 2 apache www 12288 Oct  1 15:32 storage/framework/sessions

这些权限对于会话目录是否正确,还是我需要更改权限?

我还需要做些什么来解决这个 419 问题吗?

标签: laravelcsrflaravel-8

解决方案


推荐阅读