Do cleanup activities when user closes the browser

0
Hi All,We want to implement certain cleanup activities when a user forcefully close the browser. Earlier (I beleive in Version 7 or Version 8) we used to have a component to achieve the same. Now I could not find it (v 9.24.29).Do anyone of has an idea whether we have similar components (preferably Platform supported) pls provide the sameRegardsAjay
asked
1 answers
1

Hi Ajay,


In Mendix 9, we don’t really have a platform-supported component anymore to handle actions when a user forcefully closes the browser or tab. Earlier versions did have some widgets for this, but they’re not available now.


You can still try a workaround using JavaScript (window.onbeforeunload) through an HTML snippet or JS action to trigger a microflow, but just a heads-up—this isn’t fully reliable and depends a lot on browser behavior. Because of that, the safer and recommended approach is to handle cleanup on the backend side, like using session timeout logic or scheduled events, since Mendix sessions don’t end immediately when the browser is closed.


So overall, there’s no guaranteed way to run logic exactly at browser close, and a combination of frontend workaround + backend cleanup usually works best.


Hope this helps!

answered