zedsta
05-31-2011, 04:04 PM
Hi all,
I have a problem im looking for help to resolve, the objective is to load a new DIV using a cookie, which then expires after a set time and reverts back to showing the original DIV?
I would only want the above to happen if the user came to the site from a specific URL eg: http://www.example.com/promotion/
In which case the cookie is set and the new DIV is loaded this would then apply site wide until the cookie expires??
I have come across the following in the forums:
<?php
$revisit = false;
if(isset($_COOKIE['div'])){
$revisit = true;
} else {
setcookie('div', true, 5184000 + time()); //hold fo 2 months
$revisit = false;
}
?>
Then where you want your divs put:
<?php
if($revisit){
echo "<div>You've been here</div>"
} else {
echo "<div>Its your first time!</div>
}
?>
Is there anyway this is achievable??
Many thanks in advance...
I have a problem im looking for help to resolve, the objective is to load a new DIV using a cookie, which then expires after a set time and reverts back to showing the original DIV?
I would only want the above to happen if the user came to the site from a specific URL eg: http://www.example.com/promotion/
In which case the cookie is set and the new DIV is loaded this would then apply site wide until the cookie expires??
I have come across the following in the forums:
<?php
$revisit = false;
if(isset($_COOKIE['div'])){
$revisit = true;
} else {
setcookie('div', true, 5184000 + time()); //hold fo 2 months
$revisit = false;
}
?>
Then where you want your divs put:
<?php
if($revisit){
echo "<div>You've been here</div>"
} else {
echo "<div>Its your first time!</div>
}
?>
Is there anyway this is achievable??
Many thanks in advance...