I have a situation where I need to push visitors back to a welcoming page if they've not visited the site previously. I have implemented it in the drupal index.php page, however it doesn't seem to be reliably working so I wanted to post this for review, comments and suggestions as to the proper way to control this. Perhaps there is even a module that I'm missing that would be better suited so please advise as you see fit:
index.php: *** BEGIN PASTE *** <?php //... First Drupal Comments ... // BEGIN OUR FUNCTIONS // if they're new, send them back to the welcome page, else, check if they come from signup and set has_visited
$referring_url = $_SERVER['HTTP_REFERER']; // get the referring URL, looking for http://www.mydomain.com/welcome/ $position_result = strpos($referring_url, "welcome");
if ( ($position_result > 0) || isset( $_COOKIE['has_visited'] ) ) { setcookie("has_visited", true, time()+7776000); } else { header('Location:/welcome/index_main_site_entry.php'); }
// END OUR FUNCTIONS
echo $_SESSION['HTTP_REFERER']; //... rest of index.php ... *** END PASTE ***
ALSO, in the index_main_site_entry.php file I would like to test to see if has_visited has been set so that I can pass them on into the site, but I've not been able to make that one work reliably at all.
Thanks in advance for your input!
-George