One-Time Forwarding in PHP
Or ‘how to make a splash-screen that won’t excessively annoy your users’.
This isn’t a perfect mechanism, but I think it works pretty well, and it avoids any dreaded client-side Javascript-forwarding.
So the goals were:
- when the user visits the homepage, forward automatically to the splash page.
- when the user visits consecutive times, such as by following a link from the splash-page, do _not_ forward.
The obvious solution is to use a cookie to store whether they’ve seen it. But there’s an obvious problem with this approach: If the user has disabled cookies, they will always be forwarded and the main content will be inaccessible to them.
The answer would seem to be simply: Set a cookie, then force a reload and check if the cookie exists. But that wastes everyone’s time when the cookie can simply be checked from the splash page.
The code is as follows. At the top of the main index.php file, goes:
if (!isset($_GET['nosplash']))
if (!(isset($_COOKIE['splashseen'])))
{
setcookie(’splashseen’, ‘1′, time()+60*60*24, ‘/’);
header(”Location: /special/christmas2004/?splash”);
}
And inside the splashpage’s index.php,
if (isset($_GET['splash']))
if (!(isset($_COOKIE['splashseen'])))
header(”Location: /?nosplash”);
This way, non-cookie users never see the splashpage at all. But that’s better than only seeing it. If you missed it, here it is.
Mike

Posted at 4:02 pm on December 31st by Daniel.
Posted at 4:02 pm on December 31st by Mike.
Posted at 4:02 pm on December 31st by Daniel.
Posted at 4:02 pm on December 31st by Jon Berg.
Posted at 4:02 pm on December 31st by Mike.