Hey Everyone, I'm in need of a script that will load a file if it can't find a cookie on that persons computer and then write a cookie to that user, does anyone know of a script that could do this. + Rep for best answer! Thanks!
<?php if(isset($_COOKIE['whatever'])){ require_once('thefile.php'); }else{ setcookie('whatever,'true', time() + (900*1100)); } ?> PHP:
oh wait, I forgot "true" is reserved <?php //if the cookie isn't set, if($_COOKIE['whatever']!=1){ //make a file named "myfile.php", and put it in the same directory as this scripts in //there's other ways to do this that may be better depending on your situation //but this is the easiest and will work for you require_once('thefile.php'); }else{ //set the cookie setcookie('whatever,'1', time() + (900*1100)); } ?> PHP:
Whooops, this will flag a warning message if the variable is not set. Try: if (!empty($_COOKIE['whatever']))