كتاب الرؤيا
42  
The Book of Dreams
Sahih Muslim 2261 g

Abu Salama reported:

I used to see (such horrible dreams) that I fell ill. I saw Abu Qatada who also said: I used to see dreams which made me sick until I heard Allah's Messenger (ﷺ) as saying: Good dreams are from Allah, so if any one of you sees which he likes he should not disclose it to one but whom he loves, but if he sees something which he does not like he should spit on his left side thrice and seek refuge with Allah from the mischief of the Satan and its mischief (i.e. of the dream), and he should not relate it to anyone, then it would not harm him.
حَدَّثَنَا أَبُو بَكْرِ بْنُ خَلاَّدٍ الْبَاهِلِيُّ، وَأَحْمَدُ بْنُ عَبْدِ اللَّهِ بْنِ الْحَكَمِ، قَالاَ حَدَّثَنَا مُحَمَّدُ، بْنُ جَعْفَرٍ حَدَّثَنَا شُعْبَةُ، عَنْ عَبْدِ رَبِّهِ بْنِ سَعِيدٍ، عَنْ أَبِي سَلَمَةَ، قَالَ إِنْ كُنْتُ لأَرَى الرُّؤْيَا تُمْرِضُنِي - قَالَ - فَلَقِيتُ أَبَا قَتَادَةَ فَقَالَ وَأَنَا كُنْتُ لأَرَى الرُّؤْيَا فَتُمْرِضُنِي حَتَّى سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ ‏ "‏ الرُّؤْيَا الصَّالِحَةُ مِنَ اللَّهِ فَإِذَا رَأَى أَحَدُكُمْ مَا يُحِبُّ فَلاَ يُحَدِّثُ بِهَا إِلاَّ مَنْ يُحِبُّ وَإِنْ رَأَى مَا يَكْرَهُ فَلْيَتْفِلْ عَنْ يَسَارِهِ ثَلاَثًا وَلْيَتَعَوَّذْ بِاللَّهِ مِنْ شَرِّ الشَّيْطَانِ وَشَرِّهَا وَلاَ يُحَدِّثْ بِهَا أَحَدًا فَإِنَّهَا لَنْ تَضُرَّهُ ‏"‏ ‏.‏
Reference : Sahih Muslim 2261g
In-book reference : Book 42, Hadith 7
USC-MSA web (English) reference : Book 29, Hadith 5619
  (deprecated numbering scheme)