Can we expire Liferay session using javascript ?Can we expire Liferay session using javascript ?https://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1044272332024-03-28T17:47:35Z2024-03-28T17:47:35ZRE: Can we expire Liferay session using javascript ?Olaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1048316712018-03-05T10:26:38Z2018-03-05T10:26:38Z<div class="quote-title">Jignesh Vachhani:</div><blockquote>Thanks Olaf. But the issue is we have actually done SSO with OAM and have requirement that when we close browser all session should be destroyed. So if we we can do something with javascript call to destroy current liferay session would be sufficient for me to handle this requirement anyhow.</blockquote><br /><br />The point is that you can't assume any callback when the browser closes - it might just go away without calling any JS. You can try if <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload">window.onbeforeunload</a> helps you with your requirement <em>under some circumstances</em> - but just don't rely on this to always be firing. And especially <em>with SSO</em> being active, if it is indeed working, this will be <em>specifically annoying</em>: I'm assuming that you're also logging out of SSO when you close a window... Now imagine that you're working in different windows/tabs and you're closing one. <br /><br />Or you're closing a Liferay window, but have another one open, that happens to use login through the same SSO. <br /><br />I'm not sure that your users will appreciate the "added security" by being constantly logged out, just because they closed one of many windows, and possibly even unrelated applications.Olaf Kock2018-03-05T10:26:38ZRE: Can we expire Liferay session using javascript ?Jignesh Vachhanihttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1048280402018-03-05T09:16:22Z2018-03-05T09:16:22ZThanks Olaf. But the issue is we have actually done SSO with OAM and have requirement that when we close browser all session should be destroyed. So if we we can do something with javascript call to destroy current liferay session would be sufficient for me to handle this requirement anyhow.Jignesh Vachhani2018-03-05T09:16:22ZRE: Can we expire Liferay session using javascript ?Olaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1044664892018-02-24T09:21:08Z2018-02-24T09:21:08ZA way to work around this is to have really short session durations and rather use Javascript to extend the session as long as the browser is open. This way, the session can legitimately expire a few minutes after the browser closes.Olaf Kock2018-02-24T09:21:08ZRE: Can we expire Liferay session using javascript ?David H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1044411712018-02-23T19:32:11Z2018-02-23T19:32:11Z<div class="quote-title">Jignesh Vachhani:</div><blockquote>I want to kill session when user closes the browser window.</blockquote><br /><br />Not possible. Closing the browser kills everything in it, so you cannot somehow take back control to close session.David H Nebinger2018-02-23T19:32:11ZRE: Can we expire Liferay session using javascript ?Amos Fonghttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1044404152018-02-23T18:30:21Z2018-02-23T18:30:21ZSend a request to /c/portal/expire_session?Amos Fong2018-02-23T18:30:21ZRE: Can we expire Liferay session using javascript ?Jignesh Vachhanihttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1044369392018-02-23T18:06:49Z2018-02-23T18:06:49ZThanks David.<br />That's true but I want to kill session when user closes the browser window. This is one of our requirement to achieve.<br />Do you have any clue here ?Jignesh Vachhani2018-02-23T18:06:49ZRE: Can we expire Liferay session using javascript ?David H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1044292332018-02-23T15:44:23Z2018-02-23T15:44:23ZYou don't need a JS solution.<br /><br />Just redirect to /c/portal/logout.David H Nebinger2018-02-23T15:44:23ZCan we expire Liferay session using javascript ?