Answer the question
In order to leave comments, you need to log in
How else can you store cookies in curl?
Hello dear, I have a question about storing and writing cookies in curl. Namely, I am interested in the ability to store the received cookie data from the server, for example, in the mysql database
// CURLOPT_COOKIEJAR Место записи кукисов полученных с сервера
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
// CURLOPT_COOKIEFILE Источник чтения для отправки на сервер
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookie.txt');
Answer the question
In order to leave comments, you need to log in
First, tell cURL to store the cookie in memory, the empty string here is the magic value:
Then read the cookie into a variable:
After that, parse the received string and write the cookies wherever you want. To use them, it is enough to form a new string and pass it to cURL viacurl_setopt($curl, CURLOPT_COOKIE, $newCookies);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question