Hi,
It should work automatically. Please check your portal-dispatcher-spring.xml. There you will find this code:
<!-- Default exception handlers from CUBA -->
<bean class="com.haulmont.cuba.portal.sys.exceptions.PortalExceptionResolver">
<property name="noUserSessionUrl" value="/login"/>
<property name="noMiddlewareConnectionUrl" value="/maintain"/>
</bean>
PortalExceptionResolver redirects to /login if NoUserSessionException occurred from middle ware.
Please note that cuba.userSessionExpirationTimeoutSec should be set for core module, not for portal.