Question
If a cot is in front and a person is lying on it, is it valid to pray behind him?
Answer
الحمد لله، والصلاة والسلام علىٰ رسول الله، أما بعد!
Yes, it is valid to pray. The evidence for this is found in Sahih al-Bukhari. Aisha (may Allah be pleased with her) narrates:
I used to lie in front of the Messenger of Allah ﷺ in the way a bier is placed in front of the imam who leads the funeral prayer, while he ﷺ was performing the prayer. When he ﷺ intended to pray the Witr, he would wake me up and I would pray the Witr as well.
The Words of the Hadith
عَنْ عَائِشَةَ قَالَتْ: كَانَ النَّبِیُّ ﷺ وَأَنَا رَاقِدَةٌ مُعْتَرِضَةٌ عَلَی فِرَاشِهِ فَإِذَا أَرَادَ أَنْ یُوْتِرَ أَیْقَظَنِیْ فَأَوْتَرْتُ۔
The Ruling on the Issue
This hadith makes clear that praying in the situation mentioned in the question is permissible, whether the prayer is obligatory or voluntary.
This is because, with regard to the etiquette and requirements of prayer, there is no fundamental difference between the obligatory and the voluntary prayer.
ھذا ما عندي واللہ أعلم بالصواب