我在PHP Curl和Cookies身份验证方面遇到了一些问题.
我有一个文件Connector.php,它对另一台服务器上的用户进行身份验证,并返回当前用户的cookie.
问题是我想用curl验证成千上万的用户,但它一次只为一个用户验证和保存COOKIES.
connector.php的代码是这样的:
<?php
if(!count($_REQUEST)) {
die("No Access!");
}
//Core Url For Services
define ('ServiceCore', 'http://example.com/core/');
//Which Internal Service Should Be Called
$path = $_GET['service'];
//Service To Be Queried
$url = ServiceCore.$path;
//Open the Curl session
$session = curl_init($url);
// If it's a GET, put the GET data in the body
if ($_GET['service']) {
//Iterate Over GET Vars
$postvars = '';
foreach($_GET as $key=>$val) {
if($key!='service') {
$postvars.="$key=$val&";
}
}
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, …Run Code Online (Sandbox Code Playgroud)