我使用提供此错误的第三方API作为结帐流程的一部分使用了网页:
警告:session_start()[function.session-start]:无法发送会话cookie - 已经在第1行的/upgrades/upgradevip.php中发送的(在/upgrades/upgradevip.php:1中开始输出)的头文件
警告:session_start()[function.session-start]:无法发送会话缓存限制器 - 已在第1行的/upgrades/upgradevip.php中发送的标头(在/upgrades/upgradevip.php:1处开始输出)
我需要更改php代码中的哪一行才能使其正常工作?
以下是代码:
<?php session_start();
include('./includes/config.php');
include('./includes/functions.php');
include('./lib/recurly.php');
$message='';
// Required for the API
Recurly_Client::$apiKey = API_KEY;
// Optional for Recurly.js:
Recurly_js::$privateKey = PRIVATE_KEY;
$acc=get_querystring_var_val('account');
$plan=get_querystring_var_val('plan');
$subid=get_querystring_var_val('subid');
$aff=get_querystring_var_val('aff');
$firstname=get_querystring_var_val('firstname');
$lastname=get_querystring_var_val('lastname');
$email=get_querystring_var_val('email');
$phonenumber=get_querystring_var_val('phonenumber');
$brand=get_querystring_var_val('brand');
$zip=get_querystring_var_val('zip');
if(isset($_POST['process']) && $_POST['process'] =='1'){
/*
* get all session info to process
*/
$selCardType=get_session_val('selCardType');
$txtCCNumber=get_session_val('txtCCNumber');
$txtSecurityCode=get_session_val('txtSecurityCode');
$selMonth=get_session_val('selMonth');
$selYear=get_session_val('selYear');
$account_code=$acc;
if($account_code!=''){
/*
* process transaction
*/
$transaction = new Recurly_Transaction();
$transaction->description = $upsell_description;
$transaction->amount_in_cents = $upsell_amount_in_cents;
$transaction->currency = CURRENCY_CODE;
$account = new Recurly_Account();
$account->account_code = $account_code;
$billing_info = new Recurly_BillingInfo();
$billing_info->first_name = $firstname;
$billing_info->last_name = $lastname;
$billing_info->number = $txtCCNumber;
$billing_info->verification_value = $txtSecurityCode;
$billing_info->month = $selMonth;
$billing_info->year = $selYear;
$billing_info->zip = $zip;
$account->billing_info = $billing_info;
$transaction->account = $account;
$success=false;
try{
$transaction->create();
$success=true;
}catch(Exception $e){
$message='There was problem processing your request.' . $e;
}
if($success){
/*
* set one time transaction details in session
*/
try {
$transactions = Recurly_TransactionList::getForAccount($account_code);
foreach ($transactions as $transaction) {
//print "$subscription\n";
//echo '<br/><br/>';
$_SESSION['onetime_receipt']=$transaction->uuid;
}
} catch (Recurly_NotFoundError $e) {
//$message= "Transaction not found" . $e;
}
header('Location: /congratulations2deff5-us.php?account='. $acc.'&plan=' . $plan.'&subid=' . $subid.'&aff='.$aff.'&firstname='.$firstname.'&lastname=' .$lastname. '&email=' .$email .'&phonenumber='.$phonenumber.'&brand=' . $brand . '&zip=' . $zip);
exit;
}else{
//ideally this is place to set a variable to show a form which asks a user to fill contact info and cc info agaian
$message='Transaction could not be processed';
}
}else{
$message='There was problem processing your request.';
}
}
?>
答案 0 :(得分:1)
如果您在开始<?php
标记之前确实有空格,请将其删除。
答案 1 :(得分:0)
试试这样:
<?php
session_start();
并删除之前的前导空格
答案 2 :(得分:0)
检查这个php文件是否先加载(例如 - 这是“index.php”),但不包括在index.php或其他地方