What you need to do is create a proper login system using something like
a session. There are countless tutorials you'll find about this by googling
"php login tutorial with session". Here is one of those results.
At the heart of all of these are PHP Sessions, which allow you to store
information for a specific client throughout their browser session. To
understand sessions in php, here's a basic
Let me know if these make sense or if you have any questions :)