It was authentically reported in the Sunnah in many Hadiths that the Prophet (peace be upon him) instructed Muslims to what they should say or do when they see something pleasant or bad in sleep.
Of these Hadiths what was reported by Al Bukhari in his Sahih (book of authentic Hadiths) on the authority of Abu Sa`id Al Khudry (may Allah be pleased with him) that he heard the Prophet (peace be upon him) saying: "If anyone of you sees a dream that he likes, then it is from Allah, and he should thank Allah for it and narrate it to others. However, if a person sees something he does not like, i.e., a dream that a person dislikes, then it is from Satan, and he should seek refuge with Allah from its evil, and he should not mention it to anybody, for it will not harm him." [Sahih Al Bukhari No. (6985)].
It was reported in Sahih Al Bukhari and Sahih Muslim from the Hadith of Abu Salamah (may Allah be pleased with him) who said: I used to see a dream which would make me sick till I heard Abu Qatada saying: I too, used to see a dream which would make me sick till I heard the Prophet (peace be upon him) saying: A good vision is from Allah, so if anyone of you sees a dream which he likes, he should not tell it to anybody except to the one whom he loves, and if he saw a dream which he disliked, then he should seek refuge with Allah from its evil and from the evil of Satan, spit three times (on his left), and should not tell it to anybody, for it will not harm him. [Sahih Al Bukhari No. (7044) and Sahih Muslim No. (2261)].
It was reported in Sahih Muslim from the Hadith of Jabir (may Allah be pleased with him) that the Messenger of Allah (peace be upon him) said: "When one of you sees a bad dream let him spit three times on his left, seek refuge in Allah from the Satan three times (i.e., by saying: A`udhu billahi minash-Shaitanir-Rajim), and change the side on which he was lying.'' [Sahih Muslim No. (2262)].
These Hadiths contain some benefits related to vision and what should a person say when he sees something pleasant or something bad in his sleep.
Of these benefits are the following:
First, glorification of good visions which a Muslim sees and believing that they are from Allah (may He be Glorified and Exalted) to the believer as a good news and comfort for his heart as Allah (may He be Exalted) says: "For them are glad tidings, in the life of the present world (i.e. through a righteous dream seen by the person himself or shown to others), and in the Hereafter." [Surat Yunus: 64].
Many of the Pious Predecessors said: The meaning is the good vision which a pious Muslim sees by himself or another pious Muslim sees it for him.
Second, explaining that the bad dreams or nightmares which a person sees in his sleep are from Satan in order to cast sadness in those who believe, but it shall not harm them except if Allah wills. What a Muslim sees in his sleep is divided into three types:
1- The good vision which is a glad tiding from Allah to those who see it or when some pious people see it for him.
2- Bad dreams or nightmares are caused by Satan to confuse a Muslim and cast sadness to his heart.
3- The dreams, which a person sees in his sleep, are due to thoughts and ideas or views which he sees during his daily life.
Third, explanation to what should a Muslim do or say when he sees something pleasant or bad in his sleep and that is divided into several matters:
1- A Muslim should rejoice with the good vision when he sees it or when someone tells him about and should not be tempted because vision as some Pious Predecessors said: "Adds rejoice to a believer but does not tempt him."
2- A person should praise Allah (may He be Glorified and Exalted) for the good vision which Allah granted to man.
3- A person should spread this good news and inform all good people who cooperate with him for goodness and benevolence so that the good vision would be supportive to them in increasing their goodness and a motive to go forward in all fields of good.
4- A person should not narrate the good vision to someone hates him or someone wishes to inflict harm to him like envious people.