<?php
session_start();
//create array of data to be posted
//traverse array and prepare data for posting (key1=value1)
//set POST variables
$url = 'xxx/cart2.php';
$fields = array(
'ssl_merchant_id' => ('xxx'),
'ssl_user_id' => ('xxx'),
'ssl_pin' => ('xxx'),
'ssl_transaction_type' => ('xxx'),
'confirm_code' => ($_POST['confirm_code']),
'ssl_show_form' => ('xxx'),
'ssl_cardholder_ip' => ($_POST['ssl_cardholder_ip']),
'ssl_amount' => ($_POST['ssl_amount'])
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init('xxx/cart2.php');
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
echo $result;
?>
每次加载此代码时,它都会创建一个新会话!如何防止每次加载新会话?这只是我发现并修改为我自己使用的一个脚本,因为我以前从未使用过 cURL。