« Zurück zu Customization

Session Timeout

Introduction #

Session timeout is an expired time limit for a logged in Liferay user which as been inactive for a period of time.

Changing the Session Timeout Period #

There are two files that affect the length of a session timeout, which are

web.xml

, and portal.properties.

The

web.xml

is located under

/WEB-INF

. The xml element that contains the session timeout is

<session-config>
	<session-timeout>30</session-timeout>
</session-config>

The portal.properties file is located under

/portal/portal-impl/classes

. The property containing the session timeout is:

session.timeout=30

There is also a setting for a warning prior to the session timeout, which is in located in

portal.properties

under

session.timeout.warning=1

By changing this period, the timeout will increase or decrease accordingly.

Note: Session timeout values are in minutes.

Precedence #

The

web.xml

setting takes precedence over

portal.properties

.

This can be seen under

MainServlet.java

under the

_checkWebSettings()

method.

private void _checkWebSettings(String xml) throws DocumentException {
	SAXReader reader = SAXReaderFactory.getInstance(false);
	Document doc = reader.read(new StringReader(xml));
	Element root = doc.getRootElement();
	int timeout = GetterUtil.getInteger(
		PropsUtil.get(PropsUtil.SESSION_TIMEOUT));
	Element sessionConfig = root.element("session-config");
	if (sessionConfig != null) {
		String sessionTimeout =
			sessionConfig.elementText("session-timeout");
		timeout = GetterUtil.getInteger(sessionTimeout, timeout);
	}
	PropsUtil.set(PropsUtil.SESSION_TIMEOUT, Integer.toString(timeout));
 }

MainServlet.java

sets the session timeout to

PropsUtil.SESSION_TIMEOUT

.

What Uses the Session Timeout? #

session_timeout.jsp

uses the timeout to set a decreasing counter that will eventually timeout after a period of time. The file is located under

/html/common/themes

.

session_timeout

will call

PropsUtil.SESSION_TIMEOUT

to set the timeout. After the timeout is set, the code determines when a warning appears and when to terminate the session due to inactivity.

session_timeout.jsp

is usually called in a theme in a

portal_normal

file.

Note: In the

session_timeout.jsp
uses the timeout in millisecond instead of minutes. (1 minute = 60000 milliseconds)

0 Anhänge
52481 Angesehen
Durchschnitt (3 Stimmen)
Die durchschnittliche Bewertung ist 3.66666666666667 von max. 5 Sternen.
Kommentare
Antworten im Thread Autor Datum
Hi Is it possible to set session time for a... asif aftab 13. Februar 2014 03:04

Hi
Is it possible to set session time for a specific portlet which is differ from portal.
Gepostet am 13.02.14 03:04.