When a user logs in to a website successfully, that event creates a session named 'loggedin' and sets it to true.
if (criteria satisfied){
$_SESSION['loggedin'] = true;}
else { ... }
How can this session be made to expire upon the user exiting the website?
Exiting the website means directly leaving the website. Whether that be closing the tab, browser or visiting another website, it means any instance where the user leaves the website.
I have checked other questions before asking this question but none seem to answer this directly, all seem to deal with unique instances relevant to each asker.