Detect a Browser Back/Forward by PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sahaja108
Forum Newbie
Posts: 3
Joined: Mon Nov 13, 2006 8:32 am

Detect a Browser Back/Forward by PHP

Post by sahaja108 »

Hello.
I am developing a dynamic bread crumbs navigation system that was working fine until I came across the fatul "back and forward" that made it break. :(
SOS.
I was wondering if it possible to detect a Browser Back/Forward by PHP.
I mean. I am in page A, I go to page B and then I click on the Back button and I return to A.
Does it exist a php function that detect that I have used the Back button?

Thank you very much :D

Sahaja
Last edited by sahaja108 on Mon Nov 13, 2006 9:56 am, edited 2 times in total.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

PHP is server-side... and it seems as though you're trying to solve a client-side issue... I'd suggest looking at JavaScript as tool for this.
sahaja108
Forum Newbie
Posts: 3
Joined: Mon Nov 13, 2006 8:32 am

Post by sahaja108 »

thanks for the raply m3mn0n,

the problem is more complicated than what i depicted!

after your advice, i tested the system. practically, if i use Firefox and Explorer, the browser call the page from the server, but Opera not!
i have used a

echo rand();

and it returns different values for FF and IE when a i go back and forward, but the same value ion Opera!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You cache control settings can have an impact on what the browser does on back/forward. If it is that big of an issue, you should find ways to code your app so that back/forward are handled at the page load.
sahaja108
Forum Newbie
Posts: 3
Joined: Mon Nov 13, 2006 8:32 am

Post by sahaja108 »

yes, maybe i need to intercept the event back/forward at client level and then send a msg to the server what is requested a back page...

i used a session array to keep track of the dynamic breadcrumbs. the difficult with this navigation is that there are many paths leading to a same page. so i couldn't rely on a hierarchy.
but, anyway, it was working ... until i clicked on the back button: this event creats paths with funny directions.

8)
Post Reply