No, I don’t believe it’s just their imagination. Although it only happens occasionally, God apparently does give some people a glimpse of heaven’s glory. The Apostle Paul told of being “caught up to paradise,” where he experienced “inexpressible things” (2 Corinthians 12:4).
Why does God do this? The Bible doesn’t say, but perhaps one reason is to give comfort and assurance to those who’ll be left behind when a loved one dies. As a child, I recall hearing about a vision my grandmother had of heaven. It gave great comfort to her family, not only because they knew she soon would be going to heaven, but also because she glimpsed other family members who’d gone before her.
At the same time, our final assurance of heaven doesn’t come from such incidents (some of which may not even be reliable or valid). Our assurance comes instead from Jesus Christ, and from what he did for us through his death and resurrection. By his death he took upon himself the judgment for sin that we deserve, and by his resurrection he conquered death’s power over all who put their faith and trust in him. We can we know heaven is real, and we no longer need to fear death — because of Jesus.
Is your faith and confidence in him? Don’t trust your good works, or your religious activities, or anything else for your salvation, but by faith commit your life to Jesus Christ and trust him alone for your salvation. Jesus’ promise is true: “I am the resurrection and the life. He who believes in me will live, even though he dies” (John 11:25).