令牌会话无效。请再次登录。在Opencart管理员

时间:2017-05-04 08:26:12

标签: .htaccess session opencart

我的Opencart安装存在问题,我无法访问实时域上的站点管理员 - 但它在开发域上运行时具有相同的主机和设置。

没有访问令牌传递给URL - 我只是被重定向回登录屏幕,并显示错误消息“无效的令牌会话”。请再次登录。'。

如果我删除.htaccess文件,管理员将按预期工作,主页也会如此,但所有子页面都会出现错误,找不到页面错误。

我已经尝试了我找到的所有建议,例如添加session.save_path = / tmp;到php.ini并向htaccess添加order allow,deny等。

任何帮助都会很棒!

2 个答案:

答案 0 :(得分:1)

这是解决方法:
第一步: 您应该先安装vqmod,然后创建notepad.txt文件,然后将以下代码粘贴到txt文件中:

<?xml version="1.5" encoding="UTF-8"?>
<modification>
<id>Keep Admin Users Logged In - Opencart 2.x</id>
<version>1.1</version>
<vqmver>2.5.1</vqmver>
<author>Nt Solutions</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>

第二步:另存为:ntsolutions.xml
第三步:将文件ntsolutions.xml复制并粘贴到* \ vqmod \ xml
第四步:在管理员扩展/修改中清除缓存,然后点击刷新按钮

答案 1 :(得分:0)

首先检查您的PHP版本,如果它在5.2以下,它可能会显示这些错误。将其更改为PHP 5.4 +

将此添加到.htaccess以更改php版本

AddHandler x-httpd-php55 .php
55 代表php版本(5.5)

尝试使用www访问您的网站,并查看是否存在差异

确保在安装Opencart时已从rar文件夹中上传了所有文件

并确保您的OC不在子文件夹中

示例:example.com/opencart(在这种情况下,opencart会出现问题)