D
D
dllweb2016-08-17 20:01:15
PHP
dllweb, 2016-08-17 20:01:15

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');

The question regarding the recording, as I understand it, is still possible in the database, but I’m not sure about reading, I really haven’t found information anywhere on this issue and haven’t even tested it yet, but maybe someone has already met with this situation?
I suspect the possibility of using the tempname () function; just to emulate a temporary file for the stand in CURLOPT_COOKIEFILE
What do you think?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2016-08-17
@dllweb

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 via
curl_setopt($curl, CURLOPT_COOKIE, $newCookies);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question