My cookie seems to be working but I just noticed that there is a fault

Discussion in 'JavaScript' started by mikeonthebeach, Aug 29, 2009.

  1. #1
    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.
     
    mikeonthebeach, Aug 29, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    this is php. post it there.
     
    dimitar christoff, Aug 29, 2009 IP