I want to log out my joomla website when browser close event occurs. I think joomla logout only works when clear session

Please help me.


This is not tried/tested, so the best implementation is up for debate, but you could load this javascript in your template so that it is included on all pages. When the window closes, it will POST to a PHP script that you will contain the code that does the log out.

window.onbeforeunload = function(){
   // Post to script that will log the user out

Referring to this question and answer, write logmeout.php to include the Joomla Framework, and this code should do the logout:

$app = JFactory::getApplication('site');
if(JFactory::getUser()->id) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.