Thursday, 7 April 2016

How to setup Session timeout in Blogger Websites

How to setup Session timeout in Blogger

How to do Session Timeout in BLOGGER Websites.

See a ONLINE DEMO PAGE first before proceeding.
How to setup Session timeout in Blogger
If you are a blogger and you want to add this to your own website then please follow the following steps.

1. Login to Blogger.
2. Go to Template.
3. Then select Edit HTML option from the right.
4. Copy and paste the following code just before the </head> tag.

<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript">!function(a){jQuery.sessionTimeout=function(b){function c(b){switch(b){case"start":e=setTimeout(function(){a("#sessionTimeout-dialog").dialog("open"),d("start")},h.warnAfter);break;case"stop":clearTimeout(e)}}function d(a){switch(a){case"start":f=setTimeout(function(){window.location=h.redirUrl},h.redirAfter-h.warnAfter);break;case"stop":clearTimeout(f)}}var e,f,g={message:"Your session is about to expire.",keepAliveUrl:"/keep-alive",redirUrl:"/timed-out",logoutUrl:"/log-out",warnAfter:9e5,redirAfter:12e5},h=g;b&&(h=a.extend(g,b)),a("body").append('<div title="Session Timeout" id="sessionTimeout-dialog">'+h.message+"</div>"),a("#sessionTimeout-dialog").dialog({autoOpen:!1,width:400,modal:!0,closeOnEscape:!1,open:function(){a(".ui-dialog-titlebar-close").hide()},buttons:{"Log Out Now":function(){window.location=h.logoutUrl},"Stay Connected":function(){a(this).dialog("close"),a.ajax({type:"POST",url:h.keepAliveUrl}),d("stop"),c("start")}}}),c("start")}}(jQuery);</script>

		<script type="text/javascript">
				 $( document ).ready(function() {
					  warnAfter: 8000,
					  redirAfter: 13000,
					   redirUrl: 'timeout.html',
					   logoutUrl: 'logout1.html',

After integration into the blogger template, code should look like this.
Please customize the $.sessionTimeout function values as per your requirement.

How to setup Session timeout in Blogger

After this your blogger website will have session timeout functionality all throughout, among all the web pages.

Going Deeper: Some Explanation of the function call...and its customization as per requirement.
Customize this function call as per requirement.
How to setup Session timeout in Blogger

No comments:

Post a Comment

Coder Magnet
CoderMagnet is full of resources from our daily development activities. It has solutions for common problematic scenarios in technologies like Java 8, AEM, JCR and also occasionally gives you tips on Blogger as well.