How to detect a page refresh with PHP?

→ Are you a new visitor? Please visit the page guidance for new visitors ←

How to detect a page refresh with PHP?

Sometimes you want to detect if the page was refreshed using “F5” key, or right click and “Reload” or any other method available. Either way, this can be detected somehow from server side. In this snippet, I will show you how to do this with PHP.

Method one

 Method two

You can do this also based on the session, but if you go away from the site and return later in the same browser, the counter will be the same since the session didn’t changed.

 

Request an article ←