fixed redirect bug

rewrote login/logout functions