Redirect on Session Timeout
By default when session timeout occurs, Liferay will redirect to home page. In case we need to redirect to custom url we can do that by implementing SSO interface as below :
1. Create an OSGi module and place a new Java class into a package in its src folder.
2. In the @Component annotation, add service=SSO.class and implement SSO Interface as below :
import com.liferay.portal.kernel.security.sso.SSO;
import org.osgi.service.component.annotations.Component;
@Component(
immediate = true, service = SSO.class
)
public class SSOImpl implements SSO {
@Override
public String getSessionExpirationRedirectUrl(long companyId) {
// TODO Auto-generated method stub
return null;
}
@Override
public String getSignInURL(long companyId, String defaultSignInURL) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isLoginRedirectRequired(long companyId) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isRedirectRequired(long companyId) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isSessionRedirectOnExpire(long companyId) {
// TODO Auto-generated method stub
return false;
}
3. We need to override the below two methods :
@Override
public String getSessionExpirationRedirectUrl(long companyId) {
return "https://liferay.dev"; //URL where redirection should take place after session timeout
}
@Override
public boolean isSessionRedirectOnExpire(long companyId) {
return Boolean.TRUE; //To Enable Session Timeout Redirection
}
Note - Above example is done on Liferay 7.3

