title: PHP: use logged-in cURL session on normal web browser
body: <p>Good evening!</p>
  
  <p>I've an script in PHP which makes a CURL call to a remote host loggin page.
  After loggin in and keeping the session via cookiejar opt and cookiefile opt, I use the same CURL connection handler to loggin in on to the immediatly next page wich needs an upload.
  When it's done, I got the full session parameters and I can call any page I want from the site, but IN CURL!</p>
  
  <p>The idea, is that this script wich uses CURL, needs to finally be redirected to one of those pages in the remote host using the CURL session, but this is not possible, because from curl you can not show the results as a redirected page.</p>
  
  <p>So I've tried alot of options. None of em works at all.</p>
  
  <p>Schema:</p>
  
  <ul>
  <li>PHP script on a local server.</li>
  <li>Call to domain.com/loggin.php (creates curl ch)</li>
  <li>Keep curl session on cookie.txt file.</li>
  <li>Call to domain.com/loggin_2.php with the same ch (non closed last one).</li>
  <li>Full logged in on the remote site.</li>
  <li>Back to the PHP script. Need to redirect to domain.com/index.php, wich needs Session variables filled in with the full login process.</li>
  </ul>
  
  <p>What to do then?</p>
  
  <p>1) After having full loggin in, read cookies.txt file to get PHPSESSID.
  Then tried to use setcookie(), or via header("Set-cookie: ...") and immediatly after, using header("Location: domain.com/index.php").</p>
  
  <p>Doesn't work.</p>
  
  <p>2) Tried same thing via ajax call and finally document.cookie = ...</p>
  
  <p>Doesn't work.</p>
  
  <p>3) Adding a third cURL call to a file in my remote host wich prints a JSONED $_SESSION.
  Getting it on my PHP script, decoding it and loaded on my local session via foreach on any array value (foreach()...$_SESSION[$c] = $v).
  Added a session_start() before this foreach. And immediatly after, a header("Loaction: domain.com/index.php").</p>
  
  <p>Doesn't work.</p>
  
  <p>4) Added a session_write_close() before the header("Loaction: domain.com/index.php").</p>
  
  <p>Doesn't work.</p>
  
  <p>So I don't really know how to use the CURL session.</p>
  
  <p>I've tried to manually fix the PHPSESSID via Web Developer Firefox plugin. And I wrote down the curl generated session id. It perfeclty works. So, It should be possible to fix it via scripting on my php script! But I can't!</p>
  
  <p>Give me a hand, please!</p>
  
  <p>Thanks!</p>