dswqz24846 2016-02-26 07:26
浏览 210

OpenCart - “无效令牌会话”错误 - 如何立即修复并防止将来出现?

OpenCart 2.0.3.1

Problem #1: in Admin, trying to edit multiple items in multiple tabs usually results in error message "invalid token session, please login again".

Problem #2: this error message seems to happen at random intervals; I can't seem to determine the "timeout".

Problem #3: the error message appears AFTER clicking "Save", meaning all the changes are LOST. I have many tabs open with intricate changes, and I would like to know if it's possible to somehow "recover" the token session into the URL, so I can actually save them.

  • 写回答

1条回答 默认 最新

  • duanchao1002 2016-02-26 15:24
    关注

    I wrote a vQmod script to keep me logged in while the admin tabs are open. Feel free to use it. :)

    <?xml version="1.0" encoding="UTF-8"?>
    <modification>
        <id>Keep Admin Users Logged In - Opencart 2.x</id>
        <version>1.0</version>
        <vqmver>2.5.1</vqmver>
        <author>Tibor Besze</author>
    
        <file name="admin/controller/user/user.php">
            <operation error="skip">
                <search position="after"><![CDATA[class ControllerUserUser extends Controller {]]></search>
                <add trim="true"><![CDATA[
                    public function pingUser() {
                        $this->response->addHeader('Content-Type: application/json');
                        $this->response->setOutput(json_encode(1));
                    }
                ]]></add>
            </operation>
        </file>
        <file name="admin/controller/common/footer.php">
            <operation error="skip">
                <search position="before"><![CDATA[return $this->load->view('common/footer.tpl', $data);]]></search>
                <add trim="true"><![CDATA[
                    if (isset($this->session->data['token'])) {
                        $data['token'] = $this->session->data['token'];
                    }
                ]]></add>
            </operation>
        </file>
        <file name="admin/view/template/common/footer.tpl">
            <operation error="skip">
                <search position="before"><![CDATA[</body>]]></search>
                <add trim="true"><![CDATA[
                  <?php if (isset($token)) { ?>
                  <script type="text/javascript">
                    $(document).ready(function() {
                      setInterval(function() {
                        $.ajax({
                          type: "POST",
                          url: "index.php?route=user/user/pingUser&token=<?php echo $token; ?>",
                          dataType: "json",
                          timeout: 10000
                        });
                      }, 15000);
                    });
                  </script>
                  <?php } ?>
                ]]></add>
            </operation>
        </file>
    </modification>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题