{"id":11544,"date":"2016-09-20T09:37:06","date_gmt":"2016-09-20T14:37:06","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=11544"},"modified":"2016-09-20T09:48:31","modified_gmt":"2016-09-20T14:48:31","slug":"bootstrap-session-timeout","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=11544","title":{"rendered":"bootstrap-session-timeout"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Introduciton\">Introduciton<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Example\">Example<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Introduciton\"><h2>Introduciton<\/h2><\/span>\n<p>If you are using Bootstrap JavaScript library and want to display session time out warning to users, here is a very nice library:<br \/>\n* <a href=\"https:\/\/github.com\/orangehill\/bootstrap-session-timeout\">bootstrap-session-timeout<\/a><\/p>\n<span id=\"Example\"><h2>Example<\/h2><\/span>\n<p>Here is an example:<\/p>\n<pre lang=\"javascript\">\r\n$(document).ready(\r\n    function () {\r\n        var vm;\r\n\r\n        $.ajax({\r\n            url: baseUrl + 'api\/menu\/',\r\n            type: 'GET',\r\n            success: function (data) {\r\n                if (data[0]) {\r\n                    vm = new UserMenu(data[0]);\r\n                    ko.applyBindings(vm);\r\n\r\n                    var loUrl = $('#adfsLogoutURL').attr('href');\r\n                    var sessTo = $('#sessionTimeout').val();\r\n                    $.sessionTimeout({\r\n                        title: 'Session time out warning!',\r\n                        message: 'Your session is about to expire.',\r\n                        keepAliveUrl: '\/myapp\/',\r\n                        keepAlive: false,\r\n                        ignoreUserActivity: true,\r\n                        logoutUrl: loUrl,\r\n                        redirUrl: loUrl,\r\n                        warnAfter: sessTo - 180 * 1000, \/\/ warn three min before expiration\r\n                        redirAfter: sessTo,\r\n                        countdownMessage: 'You will be logged out in {timer} seconds.'\r\n                    });\r\n                }\r\n            },\r\n            error: function (xhr, status, error) {\r\n                alert(xhr.responseText + \";\" + status + \";\" + error);\r\n            }\r\n        });\r\n\r\n    });\r\n\r\n<\/pre>\n<p>Here is a screenshot of the displayed session warning message:<\/p>\n<span id=\"\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/session_timeout_1.jpg\" rel=\"attachment wp-att-11551\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/session_timeout_1.jpg\" alt=\"session_timeout_1\" width=\"606\" height=\"205\" class=\"aligncenter size-full wp-image-11551\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/session_timeout_1.jpg 606w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/09\/session_timeout_1-300x101.jpg 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/a><\/h6><\/span>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=11544\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18],"tags":[],"class_list":["post-11544","post","type-post","status-publish","format-standard","hentry","category-javascript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-30c","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11544"}],"version-history":[{"count":5,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11544\/revisions"}],"predecessor-version":[{"id":11552,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11544\/revisions\/11552"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}