This is expanded version of my comment.
Say you have this JS cookie object:
var Cookie = {
set: function(name,value,seconds) {
var date = new Date;
date.setTime(date.getTime() + (typeof seconds != "undefined" ? seconds : 1) * 1000);
document.cookie = name + "=" + value + "; expires=" + date.toGMTString() + "; path=/; domain=." + vitalPage.getDomain();
},
get: function(name){
var re = new RegExp("(?:^| )" + name + "=([^;]*)", "i");
var matches = document.cookie.match(re);
return matches && matches.length == 2 ? matches[1] : null;
},
read: function(name){
var re = new RegExp("(?:^| )" + name + "=([^;]*)", "i");
var matches = document.cookie.match(re);
return matches && matches.length == 2 ? matches[1] : null;
},
unset: function(name){
this.set(name,'',-1);
}
}
On initial page load, do this:
var sess_expires = Cookie.get('sess_expires'),
sess_remaining,
show_dialog = function() {
$('#your_dialog_id').show();
}
if (sess_expires !== null) {
sess_remaining = sess_expires - new Date();
if (sess_remaining > 0) {
window.setTimeout(show_dialog, sess_remaining); // show dialog when session expires
}
else show_dialog(); // show dialog now - session expired
}
else {
Cookie.set('sess_expires', new Date() + 1800000);
window.setTimeout(show_dialog, 1800000); // show dialog when session expires
}