I opened the modal 2 minutes before the expiry time. I want that after these 2 minutes the modal will close again and redirect to a url. how to do it? Any help would be much appreciated.
document.addEventListener("DOMContentLoaded", function() {
var expiryTime = `{{ request.session.get_expiry_age }}`;
var openModalTime = (expiryTime - 120) * 1000;
setTimeout(function() {
$('#sessionTimeoutModal').modal('show');
redirect_to_login();
}, openModalTime);
setTimeout(function() {
$('#sessionTimeoutModal').modal('hide');
window.location.href = "{% url 'login' %}";
}, (openModalTime + 121) * 1000);
});