Get last visited page

Is there a way to query what was the previously visited page? In other words: from which side I came to the current page?

Do you mean to move to the next or previous sibling? You don’t say which version you are using, so i will assume 3. Please tag your topic with the version number.

If you mean refererer data, then thats easier said than done. You would need to do that from the front end I think.

Thanks for your suggestion @jimbobrjames. In fact, I mean the latter. So there is no way to get the last visited page without using referrer data in the front end?

Not really, because that happens in the browser, not on the server.

You can set a cookie with javascript and read it back with PHP, then do your thing with the value.

See here. Setting and reading cookies with JavaScript –

You can set the cookies value with document.refererer. See here. keep in mind it will be empty if they came to the page directly, so you will need to handle that in your php.

What is your use case?

I´d like to customize some Back-To Buttons in dependence of the page the user came from. For example:

User comes from Homapage: Back to Homepage
User comes from Project overview: Back to Project overview

Working with URL-Parameters would work, but maybe there is another option?

Browsers already have back buttons. What is your reason to have additional back buttons?

You are totally alright, but the client … In the end I was able to convince them with another solution. Thanks anyway for your solutions!

Or use

<a href="javascript:history.back();" title="Back to the last webpage">Back</a>

if you need a link.

Needs running javascript in the browser of the visitor.