I am trying to log out users automatically when they close the browser or a tab. I have set:
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
in my Django settings, and it works as expected in most browsers. However, it does not seem to work in Microsoft Edge.
Is there a specific solution or workaround to make this functionality work in Edge?
I also tried using beforeunload, but it logs out the user even when the browser is refreshed:
$(document).ready(function() {
$(window).on("beforeunload", function(e) {
$.ajax({
url: "{% url 'logoutUser' %}",
method: 'GET',
});
});
});