PHP

HOW TO DO PHP CURL WITH COOKIES

INIT CURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://site.com"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true);

LOCAL SERVER CURL CALL (A)

01

SET COOKIE FILE $cookie = "cookie.txt"; curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);

LOCAL SERVER CURL CALL (B)

02

CURL FETCH $result = curl_exec($ch); $clist = curl_getinfo($ch, CURLINFO_COOKIELIST); curl_close($ch); echo $result; print_r($clist);

LOCAL SERVER CURL CALL (C)

03

REMOTE SERVER COOKIE print_r($_COOKIE);   SEND HEADER - UPDATE "TEST" COOKIE TIMESTAMP setcookie("Test", date("Y-m-d H:i:s"));

DUMMY REMOTE SERVER

04