Page 1 of 1

Request for add on for defeating session time outs.

Posted: Tue Feb 28, 2017 4:46 pm
by ashenfire
I only searched this site for 'session timout', no hits.

My site that I supposedly own, does not provide me the ability to prevent users from 'auto log out ' of my CMS or my HESK software
I am still trying to get a straight answer from 4 site hosting techs about this issue. Not promising.

So, I was wondering if there was another way to address this issue.
Imagine working on your ticket logged into HESK, enjoying how the ticket tracks your time while you work out problems
for customers. Then, you add a response to the ticket and it reloads the screen with a user login menu.

The time you tracked is lost. Most people don't remember the time they did, thats the reason why the time counter was
used in the first place, so adding the 'best guess' time into the ticket, is not as professional or useful.
This is also frustrating because different hosting sites have their own rules when they will close a customers' session.

The solution would be an add on that admin can use, that pings the host to prevent a time out. It can be subtle like once
an hour from when the ticket was opened, or a global setting when to ping, in case many tickets are open.
A setting could be allowed for when to ping, such as 20 mins, 30 min, 1 hr, 2, because these are the times that I have
witnessed are used the most.

Is this possible?

Re: Request for add on for defeating session time outs.

Posted: Tue Feb 28, 2017 6:29 pm
by Klemen
Session expiration times depend on server settings.

You can try and see if this simple trick helps you:

1. save this code as "refresh.php":

Code: Select all

<?php
/**
 *
 * This file is part of HESK - PHP Help Desk Software.
 *
 * (c) Copyright Klemen Stirn. All rights reserved.
 * https://www.hesk.com
 *
 * For the full copyright and license agreement information visit
 * https://www.hesk.com/eula.php
 *
 */

define('IN_SCRIPT',1);
define('HESK_PATH','./');

/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
require(HESK_PATH . 'inc/admin_functions.inc.php');
hesk_load_database_functions();

hesk_session_start();
hesk_dbConnect();
hesk_isLoggedIn();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="refresh" content="300">
    </head>

    <body style="background-color:transparent"></body>
</html>
2. upload refresh.php into your HESK folder, so it's accessible at:

Code: Select all

http://example.com/hesk/refresh.php
3. add this code to the footer.txt file:

Code: Select all

<?php
if (isset($_SESSION['id']))
{
?>
<iframe src="<?php echo $hesk_settings['hesk_url'] . '/refresh.php'; ?>" height="10" width="10" style="border:none;"></iframe>
<?php
}
?>

This will open the refresh.php file in an iframe and (hopefully) extend admin session every 5 minutes (300 seconds, set/modify inside refresh.php).

Let me know how it goes.

Re: Request for add on for defeating session time outs.

Posted: Wed Mar 01, 2017 8:21 pm
by ashenfire
:idea: It seems that should have helped.

I ftp'd the code to the main folder where footer.txt and refresh.php are in the same directory.
Verified all lower case.
CTRL-F5 the browser and logged into HESK.
CTRL-F5 again because I repeat a lot.

5 minutes no pop up frame.
Waited an hour and site sessioned out.

I like this idea so I will keep working on it.

I have to make sure that when I have a ticket open, it can recognize the code you presented,
not just for when I first login where I see available tickets.

Thank you

Re: Request for add on for defeating session time outs.

Posted: Thu Mar 02, 2017 7:08 am
by Klemen
This should work in background (in a hidden iframe), not show any popups.

Perhaps your sessions expire prior to 5 minutes? Try reducing 300 in refresh.php to for example 60 (every minute).

Re: Request for add on for defeating session time outs.

Posted: Thu Mar 02, 2017 4:37 pm
by ashenfire
My sessions expire every hour. Thats why I was saying I didn't see it work.
If pinging every 300 sec, I would expect that would be too much pinging
however for testing purposes I thought that would be okay.

Guess I will try it again for 60 sec just to be a completionist.

Also, will this code work under any condition?
Will it matter if my ticket is open and the time counter is running or if I am
at the main panel where you can search for tickets. Will it run on any page?

Re: Request for add on for defeating session time outs.

Posted: Thu Mar 02, 2017 5:32 pm
by Klemen
That code should display when you are logged into the admin panel; you can view a page source in the browser and see if there if there is an <iframe towards the bottom somewhere.

It's basically just a simple page reloading automatically every X seconds in an iframe.

Re: Request for add on for defeating session time outs.

Posted: Fri Mar 03, 2017 2:40 am
by ashenfire
Cautious optimism,
I think it works while editing a ticket.
Doing another trial.
Thanks!

Re: Request for add on for defeating session time outs.

Posted: Fri Mar 03, 2017 5:07 am
by ashenfire
Its confirmed to at least do more than what I was gettng before.
Hesk just lasted 2 hours without a timeout. So, this solution
is helping out alot.
Thanks again.

Re: Request for add on for defeating session time outs.

Posted: Wed Feb 14, 2018 7:23 pm
by Benoist
it works fine !

Thanks