Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Subhasis Roy
How to set session timeout for portlet in Liferay
February 18, 2013 11:40 PM
Answer

Subhasis Roy

Rank: Regular Member

Posts: 234

Join Date: January 19, 2012

Recent Posts

hi,

I want to set the session timeout in my custom portlet in Liferay. So how can I do that?

If I am not wrong writing the following lines in web.xml will set the session at portal level. Please make me correct if i am wrong.

web.xml entry:
<session-config>
<session-timeout>30</session-timeout>
</session-config>

So just want to know the session timeout at portlet level if possible.
Subhash Pavuskar
RE: How to set session timeout for portlet in Liferay
February 19, 2013 12:43 AM
Answer

Subhash Pavuskar

Rank: Regular Member

Posts: 234

Join Date: March 12, 2012

Recent Posts

Hi Subhasis,

If i am not wrong you mean to say session timeout configurable for just one portlet on page?
Prashant Mirajkar
RE: How to set session timeout for portlet in Liferay
February 19, 2013 12:45 AM
Answer

Prashant Mirajkar

Rank: New Member

Posts: 22

Join Date: November 23, 2008

Recent Posts

Refer to http://www.liferay.com/community/forums/-/message_boards/message/18948429

If your portlet is part of application i.e. other portlets in same war all sessions will have same expiry. You can also have an implementation where you specify per portlet expiry in preferences and set maxInactiveInterval accordingly. However this value has to be lower than those for war or portal.

Prashant
Subhasis Roy
RE: How to set session timeout for portlet in Liferay
February 19, 2013 1:10 AM
Answer

Subhasis Roy

Rank: Regular Member

Posts: 234

Join Date: January 19, 2012

Recent Posts

Subhash Pavuskar:
Hi Subhasis,

If i am not wrong you mean to say session timeout configurable for just one portlet on page?



I have changed the timeout value in the web.xml under "\tomcat\webapps\ROOT\WEB-INF".

<session-config>
<session-timeout>2</session-timeout>
</session-config>

Now its taking the new value and expires after 2minutes as I set and showing the popup before expiring. But i want to know whether I can set the session expire value at portlet level also or not.
Subhasis Roy
RE: How to set session timeout for portlet in Liferay
February 19, 2013 1:11 AM
Answer

Subhasis Roy

Rank: Regular Member

Posts: 234

Join Date: January 19, 2012

Recent Posts

Subhash Pavuskar:
Hi Subhasis,

If i am not wrong you mean to say session timeout configurable for just one portlet on page?



Yes you are correct.
I have changed the timeout value in the web.xml under "\tomcat\webapps\ROOT\WEB-INF".

<session-config>
<session-timeout>2</session-timeout>
</session-config>

Now its taking the new value and expires after 2minutes as I set and showing the popup before expiring. But i want to know whether I can set the session expire value at portlet level also or not.
Manish Kumar
RE: How to set session timeout for portlet in Liferay
February 19, 2013 1:15 AM
Answer

Manish Kumar

Rank: Junior Member

Posts: 94

Join Date: March 1, 2012

Recent Posts

Hello Subhasis,
You are right with the way you mentioned with web.xml. But there may be some differences if you have another portlet in the same project.
You can also check another way of session timeout by this Liferay Documentation

Thanks,
Manish Kumar.
Subhash Pavuskar
RE: How to set session timeout for portlet in Liferay
February 19, 2013 1:27 AM
Answer

Subhash Pavuskar

Rank: Regular Member

Posts: 234

Join Date: March 12, 2012

Recent Posts

Hi Subhasis,

I dont think its possible to have session timeout for one portlet and stay active on others !! Sorry if i am wrong !!
Subhasis Roy
RE: How to set session timeout for portlet in Liferay
February 19, 2013 9:27 PM
Answer

Subhasis Roy

Rank: Regular Member

Posts: 234

Join Date: January 19, 2012

Recent Posts

Manish Kumar:
Hello Subhasis,
You are right with the way you mentioned with web.xml. But there may be some differences if you have another portlet in the same project.
You can also check another way of session timeout by this Liferay Documentation

Thanks,
Manish Kumar.



Hi Manish ,

Thanks. But my concern is "Is it possible to Configure session timeout for a specific portlet in a portal page"
For example, if I have 6 portlets on a page, can I configure one to timeout after 10minutes of inactivity and the other 5 stay active? (Considering that at the portal level I already set the timeout to 30 minutes...and at one portlet only I want to set the session timeout to 10 minutes).
Manish Kumar
RE: How to set session timeout for portlet in Liferay
February 20, 2013 2:49 AM
Answer

Manish Kumar

Rank: Junior Member

Posts: 94

Join Date: March 1, 2012

Recent Posts

Hello Subhasis,
I think this is possible as we may have multiple portlets consist of separate sessions, so we can handle this separately and having timeouts independently.
But this is having a drawback that we have to handle the Theme timeout and all the portlet time out to make the synchronization.
You have to handle this case separately.
Hope this will help you.

Thanks,
Manish Kumar
David H Nebinger
RE: How to set session timeout for portlet in Liferay
February 20, 2013 5:52 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7250

Join Date: September 1, 2006

Recent Posts

You're all wrong and not thinking about the use cases...

A user logs into the portal and the portal says session timeout is 30 minutes.

User is looking at page w/ multiple portlets on it, maybe they use 1 out of 10.

So the first question is, how do you determine a timeout has been reached? One portlet is very busy, your portlet w/ the 5 minute timeout gets no activity, but that doesn't mean the whole portal should time out...

Next question is, what do you expect to happen when the timeout occurs? If you're thinking the user will be logged out or the portlet session (not servlet session) will get destroyed, you're just wrong again. Timeout only affects the servlet sessions, but does not propagate elsewhere (to logout or portlet session) because those are managed by the portal web app, not yours.

Besides, just a session expiration alone does nothing for you, as when the portlet is used again a new session would be created as if nothing happened for the user, just lost information that they'd end up grumbling about.

Long story short, no you cannot have individual portlet timeout values that have any true meaning in the portal.
Manish Kumar
RE: How to set session timeout for portlet in Liferay
February 20, 2013 6:18 AM
Answer

Manish Kumar

Rank: Junior Member

Posts: 94

Join Date: March 1, 2012

Recent Posts

Thanks David, you explained that very nicely.
If i am not wrong, I understood portlet session time out is meaningful to make all the information lost for the specific portlet, and the portal timeout is for every portlet.
We should use both timeout according to our requirement. We need to handle them separately.
Thanks,
Manish Kumar
Subhasis Roy
RE: How to set session timeout for portlet in Liferay
February 20, 2013 10:08 PM
Answer

Subhasis Roy

Rank: Regular Member

Posts: 234

Join Date: January 19, 2012

Recent Posts

Thanks for a nice explanation david.