<bdo id='T3fw4'></bdo><ul id='T3fw4'></ul>

    <i id='T3fw4'><tr id='T3fw4'><dt id='T3fw4'><q id='T3fw4'><span id='T3fw4'><b id='T3fw4'><form id='T3fw4'><ins id='T3fw4'></ins><ul id='T3fw4'></ul><sub id='T3fw4'></sub></form><legend id='T3fw4'></legend><bdo id='T3fw4'><pre id='T3fw4'><center id='T3fw4'></center></pre></bdo></b><th id='T3fw4'></th></span></q></dt></tr></i><div id='T3fw4'><tfoot id='T3fw4'></tfoot><dl id='T3fw4'><fieldset id='T3fw4'></fieldset></dl></div>

    1. <tfoot id='T3fw4'></tfoot>

    2. <small id='T3fw4'></small><noframes id='T3fw4'>

      <legend id='T3fw4'><style id='T3fw4'><dir id='T3fw4'><q id='T3fw4'></q></dir></style></legend>
    3. Yii2框架如何处理CSRF验证?

      How to handle CSRF Validation in Yii2 Framework?(Yii2框架如何处理CSRF验证?)
          <bdo id='2ie7g'></bdo><ul id='2ie7g'></ul>

          1. <small id='2ie7g'></small><noframes id='2ie7g'>

              1. <i id='2ie7g'><tr id='2ie7g'><dt id='2ie7g'><q id='2ie7g'><span id='2ie7g'><b id='2ie7g'><form id='2ie7g'><ins id='2ie7g'></ins><ul id='2ie7g'></ul><sub id='2ie7g'></sub></form><legend id='2ie7g'></legend><bdo id='2ie7g'><pre id='2ie7g'><center id='2ie7g'></center></pre></bdo></b><th id='2ie7g'></th></span></q></dt></tr></i><div id='2ie7g'><tfoot id='2ie7g'></tfoot><dl id='2ie7g'><fieldset id='2ie7g'></fieldset></dl></div>
              2. <legend id='2ie7g'><style id='2ie7g'><dir id='2ie7g'><q id='2ie7g'></q></dir></style></legend>
                  <tbody id='2ie7g'></tbody>
                <tfoot id='2ie7g'></tfoot>
                本文介绍了Yii2框架如何处理CSRF验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在 yii2 中遇到 CSRF 验证问题.验证与 gii 生成的默认表单一起工作正常,但是当我使用 html 标签编辑表单时,表单提交会引发错误的请求错误.我已禁用 csrf 验证以隐藏错误,但我想将其用于应用程序和数据验证的安全性.

                I'm having problem with CSRF Validation in yii2. The validation works fine with the default form generated by the gii but when I edit the form with html tags then the form submission throws a bad request error. I have disabled csrf validation to hide the error but I want to use this for the security of the application and data validation.

                有没有办法解决这个错误,或者有没有办法配置它在这种情况下正常工作?

                Is there any way of solving this error or is there a way of configuring it to work correctly in this scenario?

                推荐答案

                我猜,你的 html 表单没有隐藏的 _csrf 字段,它是由标准 Yii2 小部件自动生成的.

                I guess, your html form doesn't have hidden _csrf field, which is automatically generated by standard Yii2 widgets.

                所以你的自定义表单的最小代码可能是这样的:

                So the minimum code of your custom form might be like this:

                <form method="post">
                    <input type="hidden" name="<?= Yii::$app->request->csrfParam; ?>" value="<?= Yii::$app->request->csrfToken; ?>" />
                    <button type="submit"> Save </button>
                </form>
                

                这篇关于Yii2框架如何处理CSRF验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                <small id='UeN7Y'></small><noframes id='UeN7Y'>

              3. <legend id='UeN7Y'><style id='UeN7Y'><dir id='UeN7Y'><q id='UeN7Y'></q></dir></style></legend>
                  <tbody id='UeN7Y'></tbody>
                  • <i id='UeN7Y'><tr id='UeN7Y'><dt id='UeN7Y'><q id='UeN7Y'><span id='UeN7Y'><b id='UeN7Y'><form id='UeN7Y'><ins id='UeN7Y'></ins><ul id='UeN7Y'></ul><sub id='UeN7Y'></sub></form><legend id='UeN7Y'></legend><bdo id='UeN7Y'><pre id='UeN7Y'><center id='UeN7Y'></center></pre></bdo></b><th id='UeN7Y'></th></span></q></dt></tr></i><div id='UeN7Y'><tfoot id='UeN7Y'></tfoot><dl id='UeN7Y'><fieldset id='UeN7Y'></fieldset></dl></div>

                        • <bdo id='UeN7Y'></bdo><ul id='UeN7Y'></ul>
                          <tfoot id='UeN7Y'></tfoot>