before session handling