Example of using curl to store cookies in php_PHP tutorial

WBOY
Release: 2016-07-13 10:34:58
Original
1061 people have browsed it

复制代码 代码如下:

$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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!