0

[RESOLVED.. Pilot error]

This was the issue. I was not passing the variable on pageC

header('Location: pageC.php?screenname='.$screenname);

I am sending a visitor to a page that contains a variable (screenname) and pulls additional information from a database based on the variable.

IE. domain.com/page1.php?screenname=karol

page1.php then uses a session to store the variable

$_SESSION['screenname']=$_GET["screenname"];

When they bookmark this page and return, it only remembers page1.php without the variable and of course nothing from the database.

I'd like to set something up to remember the variable upon return

What approach would be best?


Yes.. Here's more

pageA.php receives the variable (screenname)

domain.com/pageA.php?screenname=karol

(pageA.php looks like this)

session_start();

$_SESSION['screenname']=$_GET["screenname"];

This page figures out if it's an Android, iPhone, or standard browser based on USER_AGENT

header('Location: pageB.php?screenname='.$screenname);

pageB.php (Records a hit to the sites statistics - This needs to be here)

$_SESSION['screenname']=$_GET["screenname"];
header('Location: pageC.php?screenname='.$screenname);

pageC.php is the page that gets bookmarked and starts with:

session_start();
$screenname = $_SESSION['screenname'];
header('Location: pageC.php);

How do I get the variable if needed from the get and still keep it upon revisit?

Phil
  • 1
  • 1

1 Answers1

0

Are you sure that bookmarks are not saved with a query strings? I have so many bookmarks that have long list of variables and values as query string. If you have served them yourdomain.com/page1.php?screename=superstar for example, when they do bookmark the page, the query string out to be also saved automatically.

I just tested it for Chrome Version 25.0. Bookmarking saves query string. The same for Mozilla Firefox 18.0 (dang, they are going insane with version numbers these days, aren't they?). IE 9 too (Favourites). Am I missing something here?

Google use # and some other sites too if the worry is that the query string may be trimmed on bookmarking. Incidentally as we know # is the real McCoy of "bookmarks" in HTML. Hashtagging is not only in the rise but has become as established as other patterns of the web 2.0. You might consider parsing urls with hashes. JavaScript location object has a key hash to natively support parsing it (making it a breeze). PHP at server end should be just a matter of string manipulation or using url related functions.