Page 1 of 1

How to change admin timeout

Posted: Fri Oct 01, 2010 2:52 am
by gmoussa73
i need some help, i installed the latest opencart version v1.4.9.1 problem is ..admin timeout is so rediculously short! my host is ipage they said:
On our platform, the maximum session time out limit is set to 60 sec. Unfortunately, it is not possible to increase this limit.
that is so not practical...i have been working on some parts for 10 and 15 minutes..then boom! logged out and all the work is lost....there should be some solution around this...i have zero knowledge of programming and php things....i just search the forum for answers of my questions and follow what the ppl instruct to do......can anyone help plz? at least if there is any solution to re-log into the same page i was working on to continue working and NOT loose all the efforts spent on it?
opencart is a very good shopping cart...i had scored some progression towards publishing my shop and start operating...we sell books...we need to spend time filling info and reviews....not fare to be kicked out and loose the work!!

Re: admin timeout......please...please...please help!!!

Posted: Fri Oct 01, 2010 8:18 am
by JAY6390
It's possible to set a timeout in javascript that would run an AJAX call to your admin area say every 30 seconds. This would mean every 30 seconds you would keep the session alive. The best advice however that I can give you is move hosts if they have such a ridiculous time limit. Also, you have to remember that you will need to also do this on the front end, otherwise your customer orders will disappear after 60 seconds of inactivity!

Re: admin timeout......please...please...please help!!!

Posted: Sat Oct 02, 2010 6:27 am
by gmoussa73
maaaaan thats so stupid...very annoying ,i cannot complete work on the shop this way???? there should be a way around it....can you explain your suggested way please? how can i do it??

Re: admin timeout......please...please...please help!!!

Posted: Sun Oct 03, 2010 6:39 am
by gmoussa73
dear jay...how to do this javascript thing? i want to try......

Re: How to change admin timeout

Posted: Wed Oct 13, 2010 11:29 pm
by i2Paq
Ask you host, it is their system that causes this.

If they cannot solve it for you: CHANGE HOST.

Re: How to change admin timeout

Posted: Sat Jul 30, 2011 11:59 am
by justinv
I used this with success:

Code: Select all

<script type="text/javascript">
function pingServer() {
    $.ajax({ url: location.href });
}
$(document).ready(function() {
    setInterval('pingServer()', 20000);
});
</script>
Put it in admin/view/template/common/header.tpl, right before the closing head tag:

Code: Select all

</head>
It calls the page you're on and discards the result every 20000 milliseconds. Change the 20000 to whatever you need - every 60000 should be enough for even the worst web host (once a minute).

Re: How to change admin timeout

Posted: Tue Aug 30, 2011 7:52 pm
by shiokguy
I am using V1.5.1.1 with default Template

I would like my Admin to auto logout after said 30 min of inactivity. How can I do that?
My admin is logon forever, and I like it to logout automatically

Regards
ShiokGuy

Re: How to change admin timeout

Posted: Tue Sep 20, 2011 11:12 pm
by obd1965
I'm looking for the same in 1.4.8

Re: How to change admin timeout

Posted: Tue Oct 11, 2011 4:30 pm
by DrunkMunki
where exactly on the server side do we change this?
is it in the php.ini file ? whats the variable?

Re: How to change admin timeout

Posted: Tue Dec 06, 2011 11:59 am
by ruslyrossi
thanks @justinv..its work for me...simple

Re: How to change admin timeout

Posted: Mon May 14, 2012 2:13 pm
by nzplayer
justinv wrote:I used this with success:

Code: Select all

<script type="text/javascript">
function pingServer() {
    $.ajax({ url: location.href });
}
$(document).ready(function() {
    setInterval('pingServer()', 20000);
});
</script>
Put it in admin/view/template/common/header.tpl, right before the closing head tag:

Code: Select all

</head>
It calls the page you're on and discards the result every 20000 milliseconds. Change the 20000 to whatever you need - every 60000 should be enough for even the worst web host (once a minute).
I have written a VQmod with your code above in it (Thanks I needed it as well).

Re: How to change admin timeout

Posted: Thu May 17, 2012 3:00 pm
by mrspeakers
I can't actually get into the header (or footer) to edit using ipage as a host. They say it's an opencart problem, but it is obviously an issue with their ftp filemanager. Anyone know any solutions?

Re: How to change admin timeout

Posted: Thu Feb 06, 2014 2:48 am
by Ampeter
I just checked your vqmod. Why did you use location.url instead of location.href? (I think location.url does not exist, at least in javascript). ???

Re: How to change admin timeout

Posted: Sun Jun 18, 2017 1:43 am
by BionicBill
I too was having this admin timeout issue and spent 2hours with my hosting provider that was looking around the web and found this tidbit
Just add this to you admin php.ini file: This set the cookie timeout to as long as the browser is open! and looks to have fixed my timeout issue,
You might also add it to your main php.ini file.

session.cookie_lifetime = 0;

Re: How to change admin timeout

Posted: Mon Nov 01, 2021 4:47 am
by TomB
I'm using version 3.0.3.8 and changed my customer and admin timeouts from 24 minutes to 1 hour by doing the following:
Note:
Changed the "Expire" timeout as kept in the database table "oc_session".
It was defaulting to 24 minutes and I changed to 3600 seconds (1 hour).

Changed (int)$this->maxlifetime)) to 3600 in the following section of code, which is in "system/library/session/db.php"
public function write($session_id, $data) {
if ($session_id) {
$this->db->query("REPLACE INTO `" . DB_PREFIX . "session` SET `session_id` = '" . $this->db->escape($session_id) . "', `data` = '" . $this->db->escape(json_encode($data)) . "', `expire` = '" . $this->db->escape(date('Y-m-d H:i:s', time() + (int)$this->maxlifetime)) . "'");
}

It becomes:
public function write($session_id, $data) {
if ($session_id) {
$this->db->query("REPLACE INTO `" . DB_PREFIX . "session` SET `session_id` = '" . $this->db->escape($session_id) . "', `data` = '" . $this->db->escape(json_encode($data)) . "', `expire` = '" . $this->db->escape(date('Y-m-d H:i:s', time() + 3600)) . "'");
}

I verified the change works by tracking the "expire" column in the oc_session table.

Re: How to change admin timeout

Posted: Mon Nov 01, 2021 7:26 am
by straightlight
TomB wrote:
Mon Nov 01, 2021 4:47 am
I'm using version 3.0.3.8 and changed my customer and admin timeouts from 24 minutes to 1 hour by doing the following:
Note:
Changed the "Expire" timeout as kept in the database table "oc_session".
It was defaulting to 24 minutes and I changed to 3600 seconds (1 hour).

Changed (int)$this->maxlifetime)) to 3600 in the following section of code, which is in "system/library/session/db.php"
public function write($session_id, $data) {
if ($session_id) {
$this->db->query("REPLACE INTO `" . DB_PREFIX . "session` SET `session_id` = '" . $this->db->escape($session_id) . "', `data` = '" . $this->db->escape(json_encode($data)) . "', `expire` = '" . $this->db->escape(date('Y-m-d H:i:s', time() + (int)$this->maxlifetime)) . "'");
}

It becomes:
public function write($session_id, $data) {
if ($session_id) {
$this->db->query("REPLACE INTO `" . DB_PREFIX . "session` SET `session_id` = '" . $this->db->escape($session_id) . "', `data` = '" . $this->db->escape(json_encode($data)) . "', `expire` = '" . $this->db->escape(date('Y-m-d H:i:s', time() + 3600)) . "'");
}

I verified the change works by tracking the "expire" column in the oc_session table.
Those changes are for DB sessions but won't rectify the issue with file sessions.