Fix query on invalid column in sessionIsValid