If one experiences a bad dream then one should turn to the left and spit thrice When spitting he should emulate the action of one who is spitting, without any saliva leaving his mouth. This action is done in order to reject the thought that Shaytaan had put in one’s heart and showing Shaytaan that this evil will not take place.
عن جابر رضي الله عنه عن رسول الله صلى الله عليه وسلم أنه قال إذا رأى أحدكم الرؤيا يكرهها فليبصق عن يساره ثلاثا وليستعذ بالله من الشيطان ثلاثا وليتحول عن جنبه الذي كان عليه (مسلم رقم 2262)
Hadhrat Jaabir (Radhiallahu Anhu) reports that Rasulullah (Sallallahu Alaihi Wasallam) said: “When you see a bad dream, then spit on your left thrice, (i.e. one should emulate the action of one who is spitting, without any saliva leaving the mouth) and thereafter seek protection of Allah Ta’ala thrice from Shaytaan, and one should change one’s sleeping position.
Source: Ihyaauddeen.co.za