setting a discount is done in the Cart object, the cart object will apply the discount if the conditions for the discount rule are satisfied, regardless of the page the user is on.
you say that reloading the confirm page resets the session variables to '', this should not be the case, the trigger for the code to set the session variables should be any form post, this would prevent the sessions from being cleared on page reload.
the discount rule should use a trigger to make sure the user ID session that is created by login is not empty, the login session would not be effected by the confirm page, it would be set by the login page.