redirect to previous page after login/logout, sort index by time