Hello again guys:
Thanks again for your help. Your script of course works perfectly. However, I had to re-open the topic as I hit the following snag, and I just can't solve it. Therefore I beg your help again.
The index page on the site I'm working on checks for a cookie. If not found, it redirects to a welcome page, and in turn, the welcome page redirects back to the index page.
By now, the cookie for the two divs has already been set, counting as the first visit. Therefore, the first time div never gets displayed.
As I see it, in order for this to work, the redirect to welcome page cookie code would need to precede the two divs cookie code, as follows:
Code:
<script type="text/javascript" src="scripts/cookie.js"></script>
<?
//test for existence of cookies... if the cookie from welcome page has not been set...
if(!$_COOKIE[userlogin]){
?>
<script type="text/javascript">
// name, value, expires, path, domain, secure
Set_Cookie( 'test', 'none', '', '/', '', '' );
// if Get_Cookie succeeds, cookies are enabled, since the cookie was successfully created.
if ( Get_Cookie( 'test' ) )
{
cookie_set = true;
// name, path, domain
// make sure you use the same parameters in Set and Delete Cookie.
Delete_Cookie('test', '/', '');
window.location = 'welcome-index.php';
}
// if the Get_Cookie test fails, cookies are not enabled for this session.
else
cookie_set = false;
</script>
<?
}
?>
<?php
$revisit = false;
if(isset($_COOKIE['div'])){
$revisit = true;
} else {
setcookie('div', true, 5184000 + time()); //hold fo 2 months
$revisit = false;
}
?>
<!-- END cookies -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
...however, in the above order the index page generates... "Warning: Cannot modify header information...(output started...index.php) in .....index.php on line..."
Is there a way to write the two codes so that they can be left in the above order?
Alternatively, if the order of the two codes is reversed, can the divs cookie code be altered to display the first time div on the second visit, and then to display the second time div as of the third visit onward?
If it helps, this is the site I'm currently working on...
billyjoeconor.com
Thanks,
Kenny
Bookmarks