Check the below code.
var sessionTimeout = "2";
var globalmins = 1;
var timeOnPageLoad = new Date();
var redirectToWelcomePageTimer = null;
var redirectToWelcomePageTimer = setTimeout('RedirectToWelcomePage()', parseInt(sessionTimeout, 10) * 60 * 1000);
var milisec = 0
var seconds = 60
var minutes = globalmins;
function display() {
if (minutes + ":" + seconds == "0.1") {
}
else {
if (milisec <= 0) {
milisec = 10
seconds -= 1
}
if (seconds <= 0) {
milisec = 0
seconds = 60
minutes -= 1
}
if (minutes <= -1) {
milisec = 0
seconds = 0
}
else
milisec -= 1
}
var timestring = "Your session will expire in " + minutes + ":" + seconds + " Minutes"
$('#showtimeleft').html(timestring);
setTimeout("display();", 100)
}
display();
function RedirectToWelcomePage() {
window.alert("Session expired. You will be redirected to some page");
window.location = "Default.aspx";
}