21,886
社区成员
发帖
与我相关
我的任务
分享
$postdata = "user=admin";
$post = array(
"post" =>$postdata
);
curl_http_open("http://www.123.com/setsession.php",$post);
function curl_http_open($url, $conf = array())
{
if (!function_exists('curl_init') or !is_array($conf)){
return false;
}
$post = '';
$purl = parse_url($url);
$arr = array('post' => true, 'return' => true, 'cookie' => '', );
$arr = array_merge($arr, $conf);
$ch = curl_init();
if ($purl['scheme'] == 'https') {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, $arr['return']);
curl_setopt($ch, CURLOPT_COOKIEJAR, $arr['cookie']);
curl_setopt($ch, CURLOPT_COOKIEFILE, $arr['cookie']);
if ($arr['post'] != false) {
curl_setopt($ch, CURL_POST, true);
if (is_array($arr['post'])) {
$post = http_build_query($arr['post']);
} else {
$post = $arr['post'];
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
session_start();
$user = $_REQUEST['user'];
//此处能取到$user值
if(!empty($user)){
$_SESSION['cuser'] = $user;
}
//
print_r($_SESSION['cuser']);