Back button

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
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Back button

Post by Ree »

Is there a way to check if the page was accessed using browser back button? I guess it's not possible, but I thought I'd ask anyway.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

the only thing i could think of would be to have a complex session system and have each link have a id on it and do somthing like that, make a little map of some sorts. it would be possible but it would be rather hard to do.


mmmaybe, when there is a link on the page it auto increments some get id on that link and then the session as well and then if the user hits back the old links might still have the same old id...somehow...and then you would be able to check that againt the session id but i don't know if this is really possible
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

using the back button on most browser will pull the page from cache, barely, if at all, hitting the server it relates to in the process. The only way you can detect such a thing is through a client-side script that checks the history object of the DOM.
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

Well, I can always make the page uncacheable.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That doesn't mean the browser won't cache it. Is it really all that necessary to put your server through the stress of serving this particular page constantly?
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

The thing is, that the pages themselves are not cached anyway (without my intention). I have a search present on the site, which actualy is taken from another site via cURL. The search form is dynamic, that is, if you select some option it automatically generates additional selection options - all of this is taken from the original site everytime a site visitor does a request. When the form is submitted, the search results are displayed (again, taken from the original site). Now if the user clicked back after submitting the form, he would see an empty form and I can't seem to do anything about it. That's why I want to check if the search form was accessed by pressing back, and then simply redirect to the fresh form. As I mentioned, the caching just does not happen when navigating through search result pages (even if I use only GET), and overall the site I take info from is on ASP .NET with a login and plus https and automatic logout, and it's very strict to what requests can be made at which point so I'm having a bit of a problem with that.
Post Reply