Seeker
Seeker

Reputation: 2475

Liferay session expire even when user is doing activities on the page

I have a portlet on my page, for all the user action we are calling the resource URLs with ajax, and only the contents inside the portlet keeps changing. Now the problem is, even though the user continuously active on the page, we are getting session expired on page. Why is this happening?

Upvotes: 1

Views: 2868

Answers (3)

Juhil Kamothi
Juhil Kamothi

Reputation: 223

Another way

If You have React/Angular/Vue (SPA) portlets or any JS Code where you can predict that the user will not reload for some time, You can use Liferay web API to extend the session whenever you want.

Liferay.Session.extend();

You can run the above code in many scenarios, Like calling Ajax Or in some functions where the user is interacting with only SPA apps. Or you can make a global timer in your portlet which extends Liferay's session automatically.

Upvotes: 0

wikimix
wikimix

Reputation: 467

You can fix this problem by following this two steps:

1- add this lines to the portal-ext.properties file:

(3000 is the number of minutes before the session will expired)

session.timeout=3000

session.timeout.warning=0

2-Go to /conf/web.xml ( Tomcat server) and edit the session configuration Timeout:

<session-config>
        <session-timeout>3000</session-timeout>
  </session-config>

Upvotes: 0

Jonny
Jonny

Reputation: 2683

Simple answer is because you're not actually navigating around Liferay. Using AJAX doesn't count as the user performing actions that stop their session expiring. You'll need the page to reload or extend the session time.

Upvotes: 1

Related Questions