Forum Moderators: coopster

Message Too Old, No Replies

Saving / Sending cookies via cURL

need help with the curl_setopt() stuff

         

jonknee

5:31 am on Aug 11, 2003 (gmt 0)

10+ Year Member



I've been running a bot for a while that goes around to a few sites and continually fetches and stores (in MySQL) data. It's been working great for about 3 months, but I'm working on some major upgrades. The next version will traverse log-ins (such as with sites like nytimes.com).

My code uses cURL (via PHP) to access the pages. I do fine with sending the POST variables, just need to know how to store/send cookies.

jpjones

7:09 am on Aug 11, 2003 (gmt 0)

10+ Year Member



To read the cookie response, just parse the headers of the response looking for the set-cookie field, and store the contents in a file or db.

To send a cookie, try using CURLOPT_COOKIE:

curl_setopt($ch,CURLOPT_COOKIE,"CheckCookie=CheckCookie; domain=.yourdomain.com; path=/");

HTH,
JP