Reputation: 853
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.
Upvotes: 0
Views: 2887
Reputation: 1690
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>
Upvotes: 1