What is the law if one forgot to recite Asher Yatzar and went to the bathroom a second time?
One who relieved himself, and forgot to recite Asher Yatzar and then went to the bathroom a second time, is not required to recite Asher Yatzar twice after the second time. Rather, he recites it one time and it also includes the first time he went to the bathroom. This applies even if after he went to the bathroom the first time he removed his mind from using the bathroom again and then changed his mind to go a second time.
Until when can the blessing of Asher Yatzar be recited?
 7/3 based on Magen Avraham 7/1; Bach; and so rules: Shlah brought in Elya Raba 7/2; Olas Tamid 7/2; Yeshuos Yaakov; Soles Belula 7/4; Nehar Shalom; Halachos Ketanos; Sheilas Yaavetz 1/15; Birkeiy Yosef 7/3; Chayeh Adam 7/7; Peri Megadim 7 M”Z 2; Ben Ish Chaiy Vayeitzei 12; Chesed Lialafim 6/4; Kitzur SH”A 4/6; Shaareiy Teshuvah 7/2; M”B 7/6; Kaf Hachaim 7/5
Other Opinions: Some Poskim rule that if one removed his mind from needing to use the bathroom a second time he needs to say the blessing twice. [Michaber 7/3, based on Teshuvos Harosh and Geonim; Levush; Taz 7/2; and Elya Raba 7/2] The reason for this is because it is similar to Davening in which case we rule that if one forgot to Daven the previous prayer he is to Daven twice by the next prayer. [M”B 7/6] The other opinions however argue that the above law is only by prayer being that it is like a sacrifice which has a law of Tashlumin. However, Asher Yatzar is a mere statement of thanks which can cover even many previous pleasures and is hence not to be said twice, just like is the law by eating. [M”B ibid; see next footnote] The Levush; Taz 7/2; and Elya Raba 7/2 defend and rule like the Michaber. The M”B ibid concludes that one is to be lenient to say it only one time, as Safek Brachos Lihakel. Admur completely omits this opinion.
Custom of Sefaradim: Although the Michaber rules to recite Asher Yatzar twice, nevertheless the rule of Safek Brachos Lihakel applies even in such a case, and hence even those that follow the Michaber are not to say Asher Yatzar twice. [Birkeiy Yosef 7/3 and so rules Ben Ish Chaiy Vayeitzei 12; Kaf Hachaim 7/5 unlike Michaber]
The law if one did not have in mind the first bathroom use when he said Asher Yatzar: See Ashel Avraham Butchach. Vetzaruch Iyun.
 This is similar to one who ate a meal and decided to end the meal and forgot to recite Birchas Hamazon, and then changed his mind and continued eating, in which case we rule he does not need to recite Birchas Hamazon twice. Rather he recites it one time and it includes also the original meal that he ate. [Admur ibid] The novelty here is that even though his decision to end the meal or not go to the bathroom anymore at this time ended the original action, a later blessing of thanks to Hashem covers also this action even if it is done after a second action.
 See M”B 7/1; Kaf Hachaim 7/6; Birkeiy Yosef 6/3
 M”B 7/6; Shaareiy Teshuvah 8/14 in his understanding of Ginas Veradim, and so seems from 6/4, although perhaps there it is only referring to Asher Yatzar of the morning which is also said as thanks for being a new creation.
 Peri Megadim 7 M”Z 2 [brought in M”B 71/]; Chayeh Adam 7/7; Yad Aaron brought in Birkeiy Yosef 6/3; See Levush 6/1 and so is implied from Admur ibid from the fact the only reason why one does not say the blessing of Asher Yatzar twice after going to the bathroom a second time is because the blessing includes also the first time, and not because the blessing of the first time is lost. Hence if one did not yet go to the bathroom a second time certainly he may still say Asher Yatzar. [So also explains Chayeh Adam ibid]
 Kaf Hachaim 7/6
 Shaareiy Teshuvah 7/1-2; Shut Yaavetz 1/15; Mor Uketzia 7; M”B 7/1; Shemen Hamaor; Rashal; Kaf Hachaim 7/6
 The reason: The Yaavetz rules that the moment one desires to use the bathroom a second time it is considered that the first pleasure is lost and hence can no longer be blessed on, just like a meal that has been digested. This explanation however does not fit in with the ruling of Admur above which clearly states that the Asher Yatzar said after the second bathroom use includes the first bathroom use. The Shemen Hamaor however explains the reason is because since he anyways needs to go to bathroom a second time let him include it within the blessing that will be said rather than say Asher Yatzar twice.
 Chesed Lialafim 6/3; Ben Ish Chaiy Vayeitzei 12; Pnei Yitzchak 1/8; Mahram Lunza brought in Matzas Shmurim 6 and Birkeiy Yosef 6/3 concludes that if some time passed, even less than one hour, one cannot say the blessing. The above ruling of 30 minutes is based on their opinion; See Kaf Hachaim 7/7; Kaf Hachaim 7/8 concludes stringently like both opinions that it may only be said within 30 minutes and only if one did not desire to use the bathroom a second time.
 The Reason: Asher Yatzar is compared to the blessing of Birchas Hamazon which may only be said before the food is digested. [Mahram Lunza ibid]
 Yabia Omer 8/22; Yechaveh Daat 4/5. He bases this on the opinion that holds one is considered satisfied by a meal for at least 72 minutes.