The Doorway Effect refers to the fact that human memory often deteriorates when one enters or leaves a room. Entering or leaving a room can disrupt memory by making it harder to recall information from the previous room and focus on the new information in the current room. This is probably because the brain sees the different places you are in as different contexts and stores information in those contexts.
The doorway effect has been investigated in various studies and seems to be a general phenomenon, and can be influenced by various factors, such as the similarity of the spaces or the type of information to be stored. One possible application of this finding is to deliberately repeat important information again just before leaving a room to ensure that it is retained in memory.
Radvansky, Gabriel A., Krawietz, Sabine A. & Tamplin, Andrea K. (2011). Walking through doorways causes forgetting: Further explorations. The Quarterly Journal of Experimental Psychology, 64, 1632-1645.
Radvansky, G. A., Krawietz, S. A., & Tamplin, A. K. (2011). Walking through doorways causes forgetting: Environmental integration. Psychonomic Bulletin & Review, 18(5), 1090-1095.
Mäntylä, T. (2013). The doorway effect: Evidence from memory experiments, practical implications. Frontiers in Psychology, 4, 1-5.
Mäntylä, T., & Rämä, P. (2013). The effect of environmental changes on prospective memory tasks. Journal of Environmental Psychology, 35, 41-50.
Stangl, W. (2014, December 4). Door effect. Online Encyclopedia of Psychology & Education.