0

Using java code and not in web.xml, I need to ensure the session is created at a particular page with no time out. Once the user goes past this page, the same session needs to have a timeout of 10 minutes.

//I am using this to set to no time limit:
session.setMaxInactiveInterval(-1);

//And i am using the same code but with different value to set the 10 minute limit:
session.setMaxInactiveInterval(TEN_MINUTES);

However, the session never times out.. which makes me think that once the sessions inactive interval is set to no limit, it cannot be undone.

I need to get this working like i described.

THANKS...

  • which value is `TEN_MINUTES` variable? – Jordi Castilla Jul 14 '15 at 14:08
  • its literaly 10 minues... 60*10. since it is set by seconds, its 60 seconds times 10 = TEN MINUTES............. + forgot to mention, that no matter what value i put instead of the 10 minutes, it still doesnt work. – Asghar Sacur Jul 14 '15 at 14:09
  • how you check if the session has timeout? did you tried first with 10 seconds or so? you notticed is **inactive** time? – Jordi Castilla Jul 14 '15 at 14:11
  • yes i tried to do 30 seconds first then 10 seconds, that works perfectly instead of -1 and 10 minutes.... i check if it is inactive by simply putting: request.getSession(false).............. this should return null if the session has become invalid. – Asghar Sacur Jul 14 '15 at 14:14
  • -1 is not valid... you must use 0... if it's working for 10 minutes there must be some backgroun request that can activate your session.... – Jordi Castilla Jul 14 '15 at 14:15
  • No, i have just tried that, 0 or -1, same thing would happen. on the first page i put 0 and the second i put 10 seconds, tried it a couple of times and the result was the same: the session does not get invalidated...... and its not just 10 minutes, any amount of seconds just does not allow it to be invalidated by timeout on the seconds page, if and only if i set it to unlimited on the first page. – Asghar Sacur Jul 14 '15 at 14:22
  • well... that only can be possible if you have same config in `web.xml` file... delete any session inactive config in `web.xml` file and check it again... – Jordi Castilla Jul 14 '15 at 14:29
  • Also think about this programmatically changes only affects the current session instance, not globally (else it would have been a static method). – Jordi Castilla Jul 14 '15 at 14:30
  • My web.xml does not have any config for session at all, the only time session gets called and time outs are updated are in these two parts. the other times all i do is set and get attributes. it would be great if you could replicate this and check if it works. thanks. – Asghar Sacur Jul 14 '15 at 15:05

0 Answers0