Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curl: Multiple Cookies

Tags:

php

curl

How can I have multiple cookies for each Client/PC to run a script?

If ComputerA run a script then cookies.txt will be created and also ComputerB run same Script then cookies.txt will be over written which is bad.

Example:

curl_setopt($ch,CURLOPT_COOKIEFILE,"cookie.txt");
curl_setopt($ch,CURLOPT_COOKIEJAR,"cookie.txt");
like image 466
I'll-Be-Back Avatar asked May 09 '26 05:05

I'll-Be-Back


1 Answers

If they're seperate computers, then it's seperate file systems and each will have its own cookie file.

But if you're on shared storage, then use a dynamic filename, perhaps

'cookie-' . $_SERVER['SERVER_NAME'] . '.txt'

instead, which'd give you

cookie-ComputerA.txt    cookie-ComputerB.txt    etc...
like image 60
Marc B Avatar answered May 11 '26 18:05

Marc B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!