legacy-knowledge-base
公開されました Sep. 10, 2025

Unable to get session state in 7.4 with call that worked in 7.2

written-by

Kenny Back

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

Issue

  • When trying to use Liferay.Session to get the session state I get a null value (utilizing specifically javascript and call Liferay.Session.get("sessionState") and the below error. This worked in 7.2, but does not in 7.4. 
VM172:1 Uncaught TypeError: Cannot read properties of undefined (reading 'get') 
at <anonymous>:1:17

Environment

  • DXP 7.4

Resolution

  • Try instead the following method logged in or out Liferay.Session.get('sessionState')
  • You could also consider Liferay.Session.extend() before it expires and invokes a call to the backend which should keep the server side session alive
  • Lastly, you could create conditions if needed like Liferay.Session !== undefined and Liferay.Session.get('sessionState') === 'expired', but both only work for signed in users and not for guest users. So you can explore the object to see what kind of returns you need to check this against

 

 

 

 

did-this-article-resolve-your-issue

legacy-knowledge-base