"Back" button (urlReferrer)

I found multiple version of answers all using javascript, but I found none of them satisfactory.

Say I have 2 cascading pages:

[color="#0000FF"][Page0] -> [Page1] -> [Page2][/color]

I go from "page0" to "page1":[color="#008000"] The urlReferrer is "page0". Which is GOOD [/color]

Then I go from "page1" to "page2" back to "page1": [color="#008000"]The urlReferrer is "page2".[/color] [color="#FF0000"]Which is WRONG[/color].

The back Url to "page1 is "page0".

[color="#008000"][size="5"]How can I setup the proper "back" url for my back button in PHP?[/size][/color]

[color="#1C2837"][size="2"]Go from [/size][/color]page0 [color="#1C2837"][size="2"]to [/size][/color]page1 [color="#1C2837"][size="2"]is HTTP Request 1 - Refferer is [/size][/color]page0

Go from page1 to page2 is HTTP Request 2 - Refferer is page1

[color="#1c2837"][size=“2”]Go back from page2 to page1 is HTTP Request 3 - Refferer is page2 - This is not mistake because HTTP is stateless protocol, and it can’t know that user at some point in the past went from page0 to page1. [/size][/color]

[color="#1c2837"][size="2"]Use $_SESSION array to resolve your issue.[/size][/color]