Discussion
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689992000/aa997d5a-3e9f-43c6-bc35-ab8a4cbc39c6.jpg?itok=ib_zqZ2a)
Apple India Pvt Ltd
IN
Last activity: 28 Jul 2021 10:44 EDT
Detect browser close event in pega
For invalidating the session upon browser close, use below script in your portal harness script files. so that it will prompt each time you close the browser like below.
Use below script in your portal harness scripts&styles by creating or updating new js file.
<script type="text/javascript">
window.addEventListener('beforeunload', function (e) {
// here you can call the logoff functionality or whatever your want
e.returnValue = '';
});
</script>