Use referer to determine redirection after login/logout.