Can someone offer any help with the code below? I have a cookie that is
set and is separated by pipes (|). For each segment, I have to look up
the id in a text file. I can loop through the cookie and get each segment,
but when I open the text file and loop through it, it only matches the
first segment.

Any help is appreciated.

<?
if(!IsSet($HTTP_COOKIE_VARS["test"])){
         setcookie("test", "43|50|77|84|", time()+31536000); /* expire in 1 
year */
}

$myCookie = explode("|",$HTTP_COOKIE_VARS["test"]);
foreach ($myCookie as $v){
         echo $v . " ";

         $links_database = "c:\\program

         files\\web_dev\\apache\\htdocs\\link.db";
         $fd = fopen($links_database, "r");
         $contents = fread($fd, filesize($links_database));

         $cookieInfo = explode("|", $contents);

         //foreach ($cookieInfo as $a){
         while(list($key, $value) = each($cookieInfo)){
                 if($v == $cookieInfo[0]){
                         print "Link Info: $cookieInfo[1]\n<br>";
                 }
         }
         fclose($fd);
}
?>

Thanks

Chris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to