session: redesigned the previous commit

Instead of checking it separately in the other part, just do it in the
same statement.