I'd like to automatically log out the user upon them closing the website.
This solution almost does it and is a good start: https://www.wix.com/corvid/forum/community-discussion/logout-on-website-leave-solved-sort-of
But I would really like to be able to detect when they log out, not when they re-visit the website, since a hacker could cheat this method by inserting some code to set the session variable before this is checked or comment out this code. However, people are much less likely to hack the website in a way that hurts themselves upon closing the website.
Just in general, seems like running code upon the 'beforeunload' event would be really nice.