Only set the session if it's not null