Posted 1 year, 9 months and 6 days ago
In few scenarios we might need to find session invalidation if user attempts to perform an operation with Liferay Asset. This scenario might be execute during client or user system is went to to idle/hibernate/sleep mode. During this time if user try to perform any operation such as Submit form or open another page etc… we need to navigate to Home page by invalidating session.
Our custom portlet build by using JQuery framework. To execute this scenario we need to find out what input device user is trying to use such as Keyboard, mouse etc… If user is performing any operation with mentioned input types then we need to reset the idle time value. If user not performed any operation for particular frequency of time then with the help of JQuery we need to redirect user request to home page,
Find below source code snippet of JQuery to perform redirect operation after certain Idle time of the portal.
Above time increment is increasing every 1 minute if user not operating anything with Keyboard or Mouse input devices. If function timeIncrement() count reached to more than 45 minutes then replacing window event to redirect to portal logout page when user perform operation with either of the input device. If user is triggered any event with either of the input device then idleTimeInterval is resetting to 0 value.