Added support for returning to the last page after logging in and out