Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Session Timeout w/o xml?

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Im trying to create a session timeout of 30sec on a html page if there is no user activity,
my problem is that if the user is busy filling in required fields(eg: 10 fields) on a form in html,
but has not yet submitted the values to a js page, then the session should stay active.
But if there is no activity on on the html page for 30sec it should auto Log Off.

A good example of what i'm trying to do is a touch phone. If there is no user interaction for
x seconds it auto locks or the light switches off.

The jsp page/function is called only once the submit button is pressed, not at every field and there are no xml pages allowed.

If is possible to do this with session timeout?

I have written my own min/sec function that auto counts down without using session but I cannot figure out how to implement an
"action listener" for actions performed on an html page.

Any ideas on how I could solve this problem or if it is at all possible?

Thanks
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i am not wrong you can try out onething, onchange or onclick of any where in the screen , process an ajax call without any action. Just a simple server hit. There by you can avoid session getting timed out.
 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Prasanna that works except onclick i just used a empty function.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the session as a timer is not an appropriate use of the session. If you need a timer, use a JavaScript timer.
 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear, I did use a timer as mentioned("I have written my own min/sec function") but the problem
still remained where I had to get an action result from the html.

Thanks
 
Bear Bibeault
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Lila Fowler wrote:but the problem still remained where I had to get an action result from the html.


You'll need to better explain what you mean by that.
 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By action I meant any input, select, search or touch performed by the user on the screen.

I didn't use session timeout as it is incorrect as I read in the other posts relating to this query, but since my html page(should only contain html, no functions) and jsp page(all functions) are separate files I was unable to figure out how to reset my timer, as the function(jsp) was only called on the submit button(eg: onclick="function" --> an action). If there where 20 html fields to be filled in then there was no way a user could complete a form like that in 30sec. I could have used the onclick() for every field to reset but that would have been messy and un-dynamic. So Prasanna pointed me the obvious solution: Create a div that calls the timeResetFunction once, due to the div property every time a field or element is pressed by the user the function is auto called resetting the timer, but if no action is done within 30 sec the logOut function activates.

I hope I have explained this better? In retrospect maybe the xml/html forum would have been a better option, but when I was asking the question I was under the impression that I would have to use js to determine if any fields where selected or actions performed maybe using mouse movement/push.

Thanks for all the help
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic