bootstrap-session-timeout

 

Introduciton

If you are using Bootstrap JavaScript library and want to display session time out warning to users, here is a very nice library:
* bootstrap-session-timeout

Example

Here is an example:

$(document).ready(
    function () {
        var vm;
 
        $.ajax({
            url: baseUrl + 'api/menu/',
            type: 'GET',
            success: function (data) {
                if (data[0]) {
                    vm = new UserMenu(data[0]);
                    ko.applyBindings(vm);
 
                    var loUrl = $('#adfsLogoutURL').attr('href');
                    var sessTo = $('#sessionTimeout').val();
                    $.sessionTimeout({
                        title: 'Session time out warning!',
                        message: 'Your session is about to expire.',
                        keepAliveUrl: '/myapp/',
                        keepAlive: false,
                        ignoreUserActivity: true,
                        logoutUrl: loUrl,
                        redirUrl: loUrl,
                        warnAfter: sessTo - 180 * 1000, // warn three min before expiration
                        redirAfter: sessTo,
                        countdownMessage: 'You will be logged out in {timer} seconds.'
                    });
                }
            },
            error: function (xhr, status, error) {
                alert(xhr.responseText + ";" + status + ";" + error);
            }
        });
 
    });

Here is a screenshot of the displayed session warning message:

session_timeout_1
This entry was posted in JavaScript. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.