Clinical death, when a person stops breathing, the heart - to pump blood, and biological death, when cells begin to disintegrate, and organs, including the brain, stop working.
In my opinion, what happens in the situation of decreasing oxygenation of the brain, and so, for example, appearing in the consciousness of the impression, images, feelings defined as the remembered effect of clinical deaths of people who, for example, survived an accident and were brought back to life is just like many other biological, psychosomatic, intelligence, etc. features are the effect of millions of years of evolutionary processes. However, how it will be interpreted and explained depends on the one hand on the lack of scientific knowledge, many questions for which we do not know the answer yet and on the other hand cultural differences, social, individual knowledge and education resources, personal experience, etc.
If your question is about human experience in this case, this is not a scientific discussion. There is no way to investigate human experience once it ceases having any connection to physical reality and therefore the question is moot.