dqphg40600
2018-04-02 12:24
浏览 116
已采纳

Yii2 CSRF令牌时间段增加

Currently I am working on Yii2 and when I go to form submit after some time then Yii2 redirect to bad request, I think there is CSRF token expire so my question is, how increase CSRF token life in Yii2?

How can we do with form submit with long time and CSRF token also validate?

CSRF token validation disable is working fine in my code but I didn't want to disable it.

No need to code show here, I think.

图片转代码服务由CSDN问答提供 功能建议

目前我正在使用Yii2,当我在一段时间后进入表单提交时,Yii2重定向到错误的请求,我 认为有CSRF令牌过期所以我的问题是,如何增加Yii2中的CSRF令牌生命?

我们如何处理长时间的表单提交和CSRF令牌也验证?

CSRF令牌验证禁用在我的代码中工作正常,但我不想禁用它。

我认为无需在此处显示代码。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douchengchen7959 2018-06-07 09:17
    已采纳

    You can use frontend and backend as different cookie and session

    Cookie Backend

    'identityCookie' => [
                    'name' => '_backendIdentity',
                    'path'=>'/admin',
                    'httpOnly' => true,
                ],
    

    Cookie Frontend

    'identityCookie' => [
                        'name' => '_frontendIdentity',
                        'path'=>'/', 
                        'httpOnly' => true,
                    ],
    

    Session Backend

    'session' => [
                'name' => 'session_backend'
            ],
    

    Session Frontend

    'session' => [
                'name' => 'session_frontend'
            ],
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题