Look at the following Jquery AJAX example:
$.ajax({
success: function(data, textStatus, xhr) {
console.log(xhr.status);
},
complete: function(xhr, textStatus) {
console.log(xhr.status);
}
});
This is based on a few assumptions and a little experience. But...
The
xhr
object has a status code. Normally when you get a redirect from the server this will be reflected in the status code returned.
3xx
The 300 code series handle your redirects. If you get one of these codes back then show the user the login page.
Your implementation may be different. You need to look at the
xhr
object for good response and a bad response. Find what's different in your implementation when you get a bad response after a session expiry and use this as the pointer to show the user the login page.