欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php使用curl存储cookie的示例_PHP教程

程序员文章站 2022-04-06 09:24:20
...
复制代码 代码如下:

$curl = curl_init();
$url = 'http://www.jb51.net/admin/gateway/login';
$data = array(
'username'=>'admin',
'password'=>'123'
);
$cookie = tempnam('./temp','cookie');
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_POST,count($data));
curl_setopt($curl,CURLOPT_POSTFIELDS,$data);
curl_setopt($curl,CURLOPT_COOKIEJAR,$cookie);
ob_start();
curl_exec($curl);
$result = ob_get_contents();
ob_end_clean();
curl_close($curl);

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/747677.htmlTechArticle复制代码 代码如下: ?php $curl = curl_init(); $url = 'http://www.jb51.net/admin/gateway/login'; $data = array( 'username'='admin', 'password'='123' ); $cookie = tempnam('./t...
相关标签: php curl cookie