Get the App
SLTechnology News&Howtos  ›  Development  › 

How does php curl set up cookie

Shulou Source: shulou.com Published: 2022-06-03 10:04:26 10月03日 Update

Php curl how to set up cookie, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Php curl sets cookie method: 1, create PHP sample file; 2, set cURL transmission options through curl_setopt function; 3, pass cookie in CURL.

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer.

How does php curl set up cookie?

The method and steps of passing cookie in PHP CURL

How do I use curl's cookie? Beginners are very headache, curl parameters are too many, of which the cookie part involves 4.

Of course, it is clearly stated in the manual that there are three cookie for curl, but there is also a parameter for header, which can include cookie.

Curl is very easy to use. The most important thing is to be familiar with the use of curl_setopt.

Curl_setopt ($ch, CURLOPT_COOKIE, $cookie)

The cookie value here should be used; separate, not with &. There is no need to use urlencode coding, of course, coding is better.

$cookie = "axibacteric caterpillar name = Fang Shiyu"

Note that when using this, not curl_setopt ($ch, CURLOPT_HTTPHEADER, $header)

The $header of contains the Cookie parameter, otherwise it will overlap, resulting in an unforeseen situation in the cookie.

Tags: Parameters novices methods coding Fang Shiyu help headaches clarity code content functions variables this situation manuals data files articles time more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Redmi OPPO Reno Shulou Tech Info