Fiqh-us-Sunnah Volume 4, Funerals and Dhikr, Fiqh 4.122A.

Section : Prayer on Dreaming Something Unpleasant.

Jabir reported that the Prophet, peace be upon him, said, -If someone of you sees an unpleasant dream he should spit three times on his left side and seek Allah’s refuge from the accursed Satan, and change the side on which he was lying.’ (Reported by Muslim, Abu Daw’ud, Nasa-i, and Ibn Majah)

Abu Sa’id Al-Khudri reported that he heard the Prophet, peace be upon him, saying, “When someone among you sees a good and pleasing dream, he should know that it is from Allah, and so he should praise and thank Allah, and describe to others what he saw in the dream. But if he sees something he dislikes then it is from Satan, so he should seek Allah’s refuge from its evil and should not mention it to anyone. It will not harm him.” (Reported by Tirmizhi, who said it is a hasan sahih hadith)