What you want to do is put that in your index.php, if you want it to redirect to another page(if someone has already been to the site) then you would beed to change that in the code. If you just want it to stay on the same page if someone has already been to your site use this:
PHP Code:
<?php
if(!isset($_COOKIE['been_here'])){
$two_months = 60 * 60 * 24 * 60 + time();
setcookie('been_here', true, $two_months);
header('Location: flash.php'); //change flash.php to your desired location for 1st timers
}
?>
And put it above everything else.
This code maybe a little bit easier for you to use:
PHP Code:
<?php
$location = array();//make an array
$location[0] = "#"; //This is the location you want it to go if someone has been to your site, if you want it to stay on the same page use #.
$location[1] = "flashIntro.html"; //This is the location you want someone to go if they have not been to your site, to stay on the same page use #.
if(isset($_COOKIE['been_here'])){ //see if the cookie exists
if($location[0]!='#'){ //if it does, check and see if the location[0] doesn't equals #
header("Location: $location[0]"); //if it doesn't redirect to location [0]
} else { //if it does
//go nowhere, stay put
}
} else { //If there isn't a cookie called been_here with a value of "true" or 1, or a true statement
$two_months = 60 * 60 * 24 * 60 + time(); //2 months
setcookie('been_here', true, $two_months); //set a cookie called been_here with a true statement
if($location[1]!='#'){ //check to see if the location[1] doesn't equal #
header("Location: $location[1]"); //if it doesn't redirect to location[1]
} else { //if it does
//go nowhere, stay put
}
}
?>
Put it above everything else.
If you want to redirect to a different page when someone has been to your site before change the value of $location[0] to the location you want it at. If you don't want it to redirect change it to '#' which tells the script to stay put.
If you want to redirect to a different page when someone has not been to your site, change the value of $location[1] to the location you want it at. If you don't want it to redirect change the value to: '#'.
Bookmarks