Only do db stuff if there is a session