小编hen*_*eak的帖子

CodeIgniter3中的csrf_regeneration为true时,如何使Ajax工作?

我目前的工作我的CI3项目,我有一些问题CSRF_Regeneration

我的目的:

当用户登录和注册时,我将使用CSRF通过检查是否存在电子邮件来保护我的表单数据,或者在用户输入电子邮件时不使用它。

如果CSRF_generation为False,那是可行的

当我将CSRF_Regeneration 配置False并且csrf_expire将在7200到期时,这是可行的。

问题当我将 CSRF_generation设置 TRUE时,将发生以下问题

POST http://localhost/com/account/register 403 (Forbidden)
Run Code Online (Sandbox Code Playgroud)

这是检查邮件是否存在的Ajax

<script type="text/javascript">
    $(document).ready(function () {

        $("#email-error").css({'display': 'none', 'color': 'red'});
        $("#email").keyup(function () {
            var emailValue = $("#email"); // This is a bit naughty BUT you should always define the DOM element as a var so it only looks it up once
            var tokenValue = $("input[name='csrf_token_name']");
//            console.log('The Email length is ' + emailValue.val().length);
            if (emailValue.val().length …
Run Code Online (Sandbox Code Playgroud)

ajax codeigniter

4
推荐指数
1
解决办法
2855
查看次数

标签 统计

ajax ×1

codeigniter ×1