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