Zend Uygulamasında curl_init kullanarak Session Error neden oluyor

2 Cevap php

Ben bu kod parçası ile benim Zend uygulamada bu garip hata alıyorum:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'www.xyz.com/ab.php');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);      

if (!isset($location->country)) {
$location = new Zend_Session_Namespace('location');
$xml = new SimpleXMLElement($data);
$location->city=$xml->City;
}

Bu bir hata, ben olsun:

Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()

When I remove that code everything works fine. Any idea ??

Edit: On further debugging I found that the error was not because of the curl code - it was ocuring later when I was assigning $location->city=$xml->City; But when I change that line to $location->city=''.$xml->City.''; It starts working..........this is driving me crazy !!!!

2 Cevap

Pek emin değil ne bir konudur, ama ben Zend_Http_Client çok güzel ve sağlam olduğunu ve CURL dahil olmak üzere birden adaptörleri için destek olduğunu söyleyebilirim.

Örnek:

$http = new Zend_Http_Client(
  'url',
   $this->options
);
$response = $http->request();

http://framework.zend.com/manual/en/zend.http.html

Sizin new Zend_Session_Namespace('location'); çağrı yeni bir oturum başlatmak için çalışacağız ama görünüşe göre bir zaten Zend_Session çağrıları kullanılmadan başlatıldı, ve böylece bir istisna atar. Yani php.ini (= 1 session.auto_start, ya da bir session_start () yerde arayın, çünkü bu olabilir) bu oturumu başlatmak nerede olduğunu bulmak için kodunuzu dinlenme (ve php.ini) kontrol edin ve gördüğünüz gibi bunu düzeltmek uygun ...