title: PHP: Cookiefile for each logged in user?
body: <p>I'm using curl to make an external call when the user clicks a button. It seems that I need to use a cookiefile / cookiejar to store some temporary information because it would not work otherwise.</p>
  
  <p>Here's a code extract:</p>
  
  <pre><code>  if (!is_dir("/tmp/cookies"))
      mkdir("/tmp/cookies");
  
  $cookie_path = "/tmp/cookies/$idHash";
  
      function curl_cookie_set($submit_url)
      {
  
      global $cookie_path;
      //sets the cookie file so the post function will work correctly
  
      $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
      $ch = curl_init(); 
      curl_setopt($ch, CURLOPT_URL, $submit_url); 
      curl_setopt($ch, CURLOPT_USERAGENT, $agent); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
      curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_path); 
      curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_path); 
      $result = curl_exec ($ch); 
      curl_close ($ch); 
  }
  </code></pre>
  
  <p>Currently, I'm creating a new cookie file for every user but was wondering if this is the most efficient way to go about it. Is there a way to store the cookie information in the session variable? Or is it possible (and feasible) to store it all in one file? What are your thoughts on this issue?</p>