My cookie seems to be working but I just noticed that there is a fault in my code. I'm not sure what is correct. I had two values in there at one point "kw" and "aid". Then I took one of them out. The "kw" seems to be working but I see that "aid" is still in my code. # Set the keyword cookie with only alpha numeric and limit length function alphanumericAndSpace( $string ) { $length = 80; return substr (preg_replace('/[^a-zA-Z0-9\s]/', '', $string),0,$length); } if (isset($_GET['kw'])) { setcookie('keyword', alphanumericAndSpace($_GET['kw']), time()+365*60*24*60); $aid = alphanumericAndSpace($_GET['kw']); } if (isset($_COOKIE['keyword'])) { $kw = alphanumericAndSpace($_COOKIE['keyword']); } Code (markup): Could anyone explain how this code works and or help me clean it up please? Thanks Mike ps "aid" was "affiliateid" but I could not get the two cookie values to work. If I could get them both to work that would be cool.