Making Up Sujud As-Sahw
Question

 
If you have to do sujud-as-sahw, but you forget and do not do it, is the prayer valid? Is there a way to make up for it after the prayer has finished or must the whole prayer be repeated? What if you remember when you are praying sunnah - should you break your prayer?
Praise be to Allah.Imam al-Mirdawi said in al-Insaf (2/154): The author– Ibn Qudamah – said that two conditions apply for sujud to be made up later:

It should be in the mosque
A long time should not have passed.

This is the right opinion, as he stated.
Imam Ahmad said: “He should do the sujud if the time that has passed is short, even if he has left the mosque.”
He also said: “He should do the sujud even if the time that has passed is long, or he has spoken or left the mosque. This is the opinion favoured by Shaykh al-Islam [Ibn Taymiyah].” (Al-Ikhtiyarat al-Fiqhiyyah, p. 94)
In Al-Rawd al-Murbi’ Sharh Zad al-Mustaqni’ (2/461) it says: 
“(If he forgets), i.e., he forgets to do the sujud as-sahw which should be done before the salam, (and he says salam), then he remembers, (he should do the sujud) and it is obligatory (if the time that has passed is short)… If he has said salam – and if a long time has passed according to what is ordinarily regarded as a long time, or he broke his wudu, or he left the mosque – he does not need to do the sujud, and his prayer is still valid.”
In Al-Sharh al-Mumti’ by Shaykh Muhammad ibn Salih al-‘Uthaymin (3/537), it says: 
“The phrase ‘If he forgets and says salam, he should still do the sujud if the time that has passed is short’ refers to the sujud that should be done before the salam, when he has already said the salam. He should do this sujud if the time that has passed is short, otherwise he no longer has to do it, and his prayer is still valid.
Examples:
A man may forget the first tashahhud, so he has to do sujud as-sahw before the salam, but he forgets and says the salam. If he remembers shortly afterwards, he should do the sujud, but if he remembers a long time afterwards, he no longer has to do it. This is why he said ‘He should do sujud if only a short time has passed. If he has left the mosque, he should not come back to do this sujud – he no longer has to do it, which is unlike when he has said salam before completing the prayer. In the latter case, he should come back and complete it, because he has omitted an obligatory act.
Shaykh al-Islam Ibn Taymiyyah said: Indeed, he should do the sujud , even if a long time has passed, because this will make up for what was missing. So when he remembers it, he should make up for it.
But the most likely opinion is that suggested by the author (may Allah have mercy on him), which is that if a long time has passed, the person no longer has to do the sujud, because sujud as-sahw is obligatory (wajib) either to make the prayer valid or it is wajib in the prayer as part of the prayer, so it is connected to the prayer and is not a separate prayer. We say that the Prophet (peace and blessings of Allah be upon him) said: “Whoever sleeps and misses the prayer, as soon as he remembers, let him pray.” (Reported by al-Bukhari (597) and Muslim (684) from the hadith of Anas) 
But we cannot use this evidence with regard to sujud as-sahw, because it is part of something else. If a person remembers soon afterwards, he should do it, otherwise he does not have to do it.” 
And Allah knows best.