For breastfeeding to have the effect of making a mahram relationship, two conditions must be met: (1) The number of breastfeeding sessions should be five or more, and (2) this should happen within the first two years of the child’s life. If these two conditions are met, then the rulings concerning breastfeeding will apply, i.e. the boy and the girl who shared the boy’s mother’s milk will be considered mahrams and marriage will be forbidden.
elaborating on breastfeeding that prohibits marriage, Dr. Muhammad As-Sayyed Ad-Disooqi, professor of Fiqh (Jurisprudence) at Qatar University, states: “In order that the fostered children become mahrams (where males become unmarriageable to females), it should be when they are under two years old. That is, breastfeeding children above two years of age does not imply being unmarriageable to one another (whether the milk is suckled or given in a cup). For example, when a woman breast-feeds a three or four year old boy – who is allowed to marry her daughter when he comes of age – breastfeeding him does not entail that the boy will be unmarriageable for the daughter. She must breastfeed him at a time when babies nurse, i.e. within the first two years.

An-Nawawi (may Allah have mercy on him) said:
“The scholars differed concerning the number of sessions of breastfeeding for which the ruling on breastfeeding (rada`ah) applies. `A’ishah and ash-Shafi`i and his companions said that there is no proof for any number less than five. The majority of scholars said that the ruling applies if breastfeeding occurs once. This was narrated by Ibn al-Mundhir from `Ali, Ibn Mas`ud, Ibn `Umar, Ibn `Abbas, `Ata’, Tawus, Ibn al-Musayyib, al-Hasan, Makhul, al-Zuhri, Qatadah, Hammad, Malik, al-Awza`i, al-Thawri and Abu Hanifah (may Allah be pleased with them). Abu Thawr, Abu `Ubayd, Ibn al-Mundhir and Dawud said: The ruling applies in the case of three sessions of breastfeeding, not less than that. Ash-Shafa`i and those who agreed with him followed the hadith of `A’ishah which mentioned five known session of breastfeeding.
Sheikh Ibn Baz was asked whether breastfeeding from a woman three times makes her a mahram.
he replied: this breastfeeding three times does not make her a mahram through breastfeeding. The ruling on becoming a mahram through breastfeeding only applies if breastfeeding occurs five times or more. Then he quoted the hadith of `A’ishah as evidence. (Source: Fatawa Islamiyyah, 3/326)
Sheikh Ibn `Uthaymeen said:
One session of breastfeeding does not have any effect, rather it must be five sessions of breastfeeding that occur before the child is weaned and before he reaches the age of two. A person does not become the woman’s (foster) child if he is breastfed once or twice or three or four times. It must also be five known sessions of breastfeeding; if there is some uncertainty as to whether he is breastfed four or five times, the principle is that it was four, because every time we are uncertain about numbers, we take the lower number. Based on this, if a woman says, I breastfed this child but I do not know if it was once or twice, or three or four or five times, we say that this child is not her (foster) child, because it has to be five known sessions of breastfeeding without a doubt. (Source: Al-Fatawa al-Jami`ah lil-Mar’ah al-Muslimah, 2/768)”