Optimize session timeout checking.