This version is old school.
Please find jQuery plugins on npm.
Jquery Session Timeout Handler
by Juan Peri
Given a certain amount of time before the session expires, a dialog is shown to the user with the option to either log out now, or stay connected. The time left of the session is retrieved from the server through ajax in json format or through configuration. This implementation with its default values works nicely with multiple tabs (as is the server who controls the time left the session has)