Patanjali Yoga Sutra — बन्धकारणशैथिल्यात् प्रचारसंवेदनाच्च चित्तस्य परशरीरावेशः ॥3.39॥
bandhakāraṇaśaithilyāt pracārasaṃvedanācca cittasya paraśarīrāveśaḥ॥
When the citta is totally free from all kinds of the bondage of karma, and by the realization of ultimate truth, a yogi can enter other’s bodies with ease, which is called parakāya praveṣa.
The sūkṣmaśarīra is bound to one physical body only due to one’s prārabdhakarmas (this is called bondage) and passage of sūkṣmaśarīra from one corporeal body to another, in the ordinary course, is only through the death of one and entry to another according to one’s karmas. Thus, this kind of transmigration is not at any one’s will but depends purely on one own saṁskāras. However, due to the accomplishment of samādhi the karmas are annihilated and the highest jñāna is also achieved. Hence in the case of a siddhayogi, who is devoid of bondages and influences of karmas, this transmigration from one corporeal body to another is at his free will and the sūkśmaśarīra and senses just follow the citta from one body to another like bees following the queen bee.
The story of Advaita philosopher, śaṅkarācārya is worth mentioning here. There was a great scholar, by name maṇḍana miśra, who advocated that gṛhastāśrama (Life of a householder — one of the caturāśramas; but modern children have invented one more āśrama called vr̥ddhāśrama) is superior to sanyāsāśrama (Asceticism). śaṅkarācārya, a sanyāsi and maṇḍana miśra, a gṛhasta, virtually debated tooth and nail on this issue and maṇḍana miśra was defeated. But, Bhārati Devi, maṇḍana miśra’s wife, stalls the acceptance of defeat of her husband by challenging śaṅkarācārya, and says, ‘My husband’s defeat is only one-half defeat. Full defeat is only when the wife is also conquered. You debate with me on ‘Sex — one of the important experiences of a householder. Being a sanyāsi, śaṅkara knew nothing about sex. However, he agrees to the challenge and asks for one month's time to come prepared.
A king by name Amarakā was on his death bed. śaṅkara decides to enter the body of Amarakā to know the experiences of gr̥hasthāśrama. He instructs his disciples to hide his body in a safe place until he returns from Amarakā’s body. Now, having entered the body of Amarakā, śaṅkara revives the dead body and starts ruling the kingdom, while enjoying gṛhastāśrama. But, Amarakā’s wife notices something strange in the behavior of the king and starts spying for the truth. Hence, śaṅkara quits the body of Amarakā at once and approaches Bhārati Devi for the resumption of debate in his own body. Now, śaṅkara is equipped with the experiences of gṛhastāśrama and ready to resume the debate with Bhārati Devi. But, Bhārati Devi understands everything with her yogic powers and acknowledges her defeat.