Script to avoid session timeout

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

eddparsons
Ebase User
Posts: 53
Joined: Wed Jan 02, 2013 4:23 pm
Location: Lyndhurst, Hampshire
Contact:

Script to avoid session timeout

#1

Postby eddparsons » Tue Aug 11, 2015 8:39 am

Hi,

Is there a script I can use to regularly refresh a form thus avoiding a session timeout?

I found http://www.webdevbros.net/2006/12/14/ke ... avascript/ while googling and have tried adding the script to the ready event of the page under HTML properties but I can't get it to work.

Regards,
Edd
0 x

User avatar
dvanhussel
Ebase User
Posts: 161
Joined: Fri Oct 19, 2007 12:45 pm
Location: Haarlem, the Netherlands

#2

Postby dvanhussel » Tue Aug 11, 2015 8:50 am

Hi,

Ik think the problem with this script is that in the 'refresh', there is no interaction with the Ebaseserver, so it's session is not updated.

Maybe you can call a dummy ebase function, or update a dummy field value. Then the server 'knows' that the form is still being used.

Something like this (not tested!):

Code: Select all

    function keepMeAlive() {
       var date = new Date();
       $eb.setFieldValue('DUMMY_FIELD', date, false);
    }
    window.setInterval(keepMeAlive, 100000);

In the form you set 'Client accessibility' property of the DUMMY_FIELD to 'Read/write'.

Regards,

David
Last edited by dvanhussel on Tue Aug 11, 2015 9:00 am, edited 2 times in total.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#3

Postby Steve James » Tue Aug 11, 2015 8:53 am

Hi Edd,
I have a button in a form that is hidden by JQuery, this has a script to simply log a statement (ie interact with the server). Then within the form html++ the following simply clicks the button every 10 minutes to keep the form alive.

Code: Select all

<script>  
$&#40;document&#41;.ready&#40;function&#40;&#41; &#123;
	setTimeout&#40;RunEvent,60000&#41;;
&#125;&#41;;

function RunEvent&#40;&#41; &#123;
   setTimeout&#40;RunEvent,600000&#41;;
	$&#40;"#TriggerButton"&#41;.trigger&#40;'click'&#41;;
&#125;
</script>
0 x

eddparsons
Ebase User
Posts: 53
Joined: Wed Jan 02, 2013 4:23 pm
Location: Lyndhurst, Hampshire
Contact:

#4

Postby eddparsons » Tue Aug 11, 2015 10:46 am

Thanks both for the replies, Steve your code works perfectly and is just what I wanted.

Thanks,
Edd
0 x


Who is online

Users browsing this forum: No registered users and 15 guests