عَنْ جَابِرِ بْنِ عَبْدِ اللَّهِ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ: ((مَا مِنْ ذَكَرٍ وَلَا أَنْثَى إِلَّا وَعَلَى رَأْسِهِ جَرِيرٌ مَعْقُودٌ ثَلَاثَ عُقَدٍ حِينَ يَرْقُدُ، فَإِذَا اسْتَيْقَظَ فَذَكَرَ اللَّهَ تَعَالَى انْحَلَّتْ عُقْدَةٌ، فَإِذَا قَامَ فَتَوَضَّأَ انْحَلَّتْ عُقْدَةٌ، فَإِذَا قَامَ إِلَى الصَّلَاةِ انْحَلَّتْ عُقَدُهُ كُلُّهَا))
It is narrated from Sayyiduna Jabir bin Abdullah (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: When every man and woman sleeps, a leather rope is tied on their head and three knots are made on their head. When he wakes up and remembers Allah Almighty, one knot is untied; when he gets up and performs ablution, the second knot is untied; and when he offers prayer, all the knots are untied.