views:

49

answers:

2

I apologize for vague title so let me explain.

Suppose you have a page with search results: http://example.com/search?q=foo. The results are:

  1. Foo - http://example.com/foo
  2. Bar - http://example.com/bar
  3. Baz - http://example.com/baz

The links above point to the item details page. On these pages I want to display links which allow to navigate through search results: Next Item, Previous Items, Back to Search Results.

So when generating a details page I need to know where the user came from, for instance I need to know which search term he used.

I could add additional query params in URLs, like http://example.com/foo?from=search&q=foo but I can't do that. The requirement is not to add any additional params to items' URLs.

Another option is to save search query in session. But it does not work if user opens several search result pages in different tabs.

How would you do that?

PS. I know there is a number of similar questions here but didn't find the one that can help in my case.

A: 

use HTTP_REFERER

Dmitriy Baranov
It won't work. Suppose I click on 1st item Foo (http://example.com/foo), then click on Next Item and go to http://example.com/bar. HTTP_REFERER will be http://example.com/foo
Andrey Fedoseev
hmm, other way - try to use anchor-based navigation (Gmail or Facebook-like).
Dmitriy Baranov
A: 

Apologies, I've never tried this before, but wouldn't hosting the page display in an iframe while the parent frame has the search navigation accomplish this?

Moses