The question is, in network
of the browser console says that cookies do not expire, see the image below:
Butwhenyoutake(makearequestofthese)thesecookieswithcurl
expire:
ct0=e3197b1390ba24c4ae827fc6740344fa;Expires=Mon,Oct232017 14:21:33UTC;Path=/;Domain=.twitter.com;Secure
Today%w/w%theynolongerwork.HowdoIgetthesecookies?
So:
$obj=newstdClass;$obj->cookies='';$obj->location='';$request=curl_init();curl_setopt_array($request,[CURLOPT_URL=>'https://twitter.com/',CURLOPT_CUSTOMREQUEST=>'GET',CURLOPT_RETURNTRANSFER=>true,CURLOPT_SSL_VERIFYHOST=>false,CURLOPT_SSL_VERIFYPEER=>false,CURLOPT_HEADER=>true,CURLOPT_COOKIEJAR=>getcwd().'/cookies/'.$username.'.txt',CURLOPT_HEADERFUNCTION=>function($curl,$header)use(&$obj){if(stripos($header,'Set-Cookie:')===0){if(preg_match('/^Set-Cookie:\s*([^=]*)=([^;]*)/mi',$header,$matches)){$obj->cookies.=$matches[1].'='.$matches[2].';';$obj->{$matches[1]}=$matches[2];}}var_dump($header);returnstrlen($header);}]);$response=curl_exec($request);
Beingthat:
if(stripos($header,'Set-Cookie:')===0){if(preg_match('/^Set-Cookie:\s*([^=]*)=([^;]*)/mi',$header,$matches)){$obj->cookies.=$matches[1].'='.$matches[2].';';$obj->{$matches[1]}=$matches[2];}}
Haveyoudonetheworksotheydonotexpirecorrectly?
EDITED
InthedocumentationItranslatedandsaysthefollowing:
Curlhasabuilt-inintegratedcookieanalysisenginethat comesintouseifyouwanttoreconnecttoaserverandusecookies thatwerestoredinapreviousconnection(ormanually manuallytotricktheserverintobelievingyouhada previousconnection).Tousepreviouslystoredcookies,you executecurlas:
curl--cookiestored_cookies_in_file link
And here's what I want:
If you want to reconnect to a server and use cookies that have been stored on a previous connection
How do I do this in PHP?