简体   繁体   中英

Can CURL request can be used set a cookie while requesting?

I'm using curl to get the contents of a webpage.. The website sets cookies when i visit them using browser..

Can i use the cURL same way and send a request to that specific website with the cookie information...????

Here are some of the option I found useful regarding curl and cookies.

 curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt' ); //use this cookie file
 curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookie.jar'); //if you close the session the cookies will be saved here
 curl_setopt($ch, CURLOPT_COOKIE,"cookie_test=yes; domain=.google.com; path=/"); //set the cookie for the current session

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM