We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10666
    • 68 Posts
    Hello.I have some problems with a very simple snippet and can’t get it to work no matter what I do sad .
    Any help would be appreciated.

    I call the following snippet uncached on some page:

    <?php
    $output='';
    $data=array(
              "affnumber"=>"620000",
              "affname"=>"George"
              );
    $output .= $data[affnumber].'<br \\>'.$data[affname].'<br \\>';
    
    if ( !isset($_COOKIE[affdata]) ) {
       $string = gzcompress(serialize($data), 9);
       setcookie("affdata", $string, time()+60*60*24*365, '/');
    }
    else {
       $mix = unserialize(gzuncompress($_COOKIE['affdata']));
    }
    
    return $output;
    ?>

    The first time I view the page , it sets a cookie named affdata with the following content:
    x%DAK%B42%B2%AA.%B6%B2%B4RJLK%CB%2B%CDMJ-R%B2.%B62%B3R232%00%02%10%C7%1C%22%99%98%9B%0A%95rO%CD%2FJ%07rj%01C%0C%12y


    However,when I view the page the second time,and the cookie is already set, the page redirects to my default error page. I tried to unserialize and gzuncompress the content from the $string var ,and print it,and all went fine,but when I try to the same with the Cookie I have , I get to the error page.

    (Maybe unrelated notes:
    1. CSS Star Rating 2.0 developed by GarryN also had some problems when using cookies.
    2. I have around 4 cookies named: SNxxxxxxxxxxx that all expire at the end of the session , and all have EXACTLY the same content , except they differ by the fact that they have different paths: domain.com , www.domain.com, www.domain.com/manager and www.domain.com/manager/includes.)

    I’m running on a linux server with:
    Mysql: Client API version 4.1.15
    and PHP Version 4.4.6
    :(