I am living in Oman, where women follow a practice of remaining in the house for 40 days following the birth of a child. I have asked several people about this. Most people do not seem to know if it is sunnah or not. If it is, I would like to try to follow the practice (I am in the 9th month of my 4th pregnancy). However, I have also been told it is a bid'ah practice and therefore I should avoid it. In sha' Allah, please try to clear up this issue, which I have been researching for almost 6 years!
Praise be to Allaah.
Forty days is the longest period that the woman in nifaas can refrain from praying and fasting, so long as blood is still flowing. After that, she should do ghusl and pray, and consider herself to be in a state of istihaadah (irregular vaginal bleeding which is neither menstruation nor nifaas) if the bleeding does not stop. Umm Salamah (may Allaah be pleased with her) said: “At the time of the Messenger of Allaah SAWS (peace and blessings of Allaah be upon him), the woman in nifaas would sit (i.e., refrain from praying and fasting) for forty days…” (Narrated by al-Tirmidhi). For more details on this topic see Question #319.
With regard to the belief that a woman has to stay in her house for forty days after giving birth and not go out, this is a mistaken belief and women do not have to do this. It is permissible for them to go out during these forty days to any place she wants, so long as she fulfils the shar’i conditions (i.e., hijaab etc.)