views:

285

answers:

1

Hello,

I have a nifty little cookie-based home page redirection scheme going for my website. Basically, the first time a user browses to the website, they are presented with two choices (Products vs. Machining Services). When the user clicks one of the two buttons, a JavaScript function stores a cookie with the appropriate choice ("products" or "machining"). This cookie is set to be stored for 365 days.

Then, the next time the user visits the root level of the website (/), the following PHP code redirects them to the proper page:

<?php

//  Pull last home page choice
$home_page_choice = $_COOKIE["HomePageChoice"];
if ($home_page_choice == "products") {
//  Redirect user to Products page
    header("Location: products/index.php");
    exit();
} else if ($home_page_choice == "machining") {
    //  Redirect user to Machining Services page
    header("Location: machining/index.php");
    exit();
} else {
    //  Redirect user to first-time user home page (where user can choose where to go)
    header("Location: home/index.php");
    exit();
}

?>

If a user happens to click back to the Site Home page, that cookie will be cleared, ready for a new choice to be made. If you ask me, it's the cleverest code ever created! ;)

The problem is, FireFox for Mac (version 3.6) just doesn't seem to redirect properly (meaning it just goes to the last 'else' page, or 'home/index.php'; FireFox 3.6 for Windows works, as does IE 8 and Safari on both platforms. I know FireFox can read the cookie; I've tested it with "echo $home_page_choice;".

So what's going on with FireFox? I figure it must be a FireFox bug of some sort since PHP is a server based language and more-or-less browser independent.

-HazMatt

A: 

you MUST (as per rfc) provide a complete url in the location header (i.e. with "http://host/"). I don't know if this solves your problem, but it's worth fixing in any case.

stereofrog
Thanks for the tip; I did update the PHP code to include the full absolute URL for all three links but alas, it does not solve the FireFox specific problem.
HazMatt