I have a login page in my app..after log in user can use the app.
Is there any way to set timeout for running application??? if app goes idle for sometime, then i want to log out the app and if user wants to use it then he has to enter the credential again..!! is there any way??
can any one suggest plzz??
thanks in advance
I can't think of any reason this would not work. But it will be up to you to determine what constitutes "activity" within the application.
You would use setTimeout() when the user first logs in, and then whenever the user does something (clicks a button, a link, opens a window, closes a window, etc.), you would use clearTimeout() and setTimeout() to reset the timer.
Store your login credentials/cookie/token/whatever in a variable. When the timeout fires, clear that credential and prompt the user for his credentials.
Here is how I would solve this:
1: User logs in: You store a
Ti.App.Property-key called 'logintime' with the timestamp like so:
Ti.App.Properties.setString('logintime', JSON.stringify(new Date()));. Loggedin = true.
2: User uses app. After a while phone goes into idle mode / standby or user exits the app.
3: In the app's window or main app.js you have an event listener for the 'resume' event. In this resume function / callback you add the logic which checks the current time and compares that with the stored 'logintime' value. If the currenttime - logintime >= the time you want the user to be logged out again, you perform the logout logic. Loggedin = false
Think you can help? Login to answer this question!