我跑隨後測試,以驗證我的代碼正常工作:
捲曲-L -i -X POST -d 'JSON = { 「ORDERBY」:0 「的maxResults」:50}' http://mysite.com/ctlClient/
我打電話:http://mysite.com/ctlClient/index.php:
session_unset();
session_start();
//pass data to _SESSION
foreach($_POST as $key => $value){
$_SESSION[$key] = $value;
}
// redirect to `/fwf/online/index.php`
ctlGotoSameDomain("/fwf/online/");
重定向後,我打電話/fwf/online/index.php
:
<?php
session_start();
....
class fwfOnline {
public function __construct() {
msqLogFile('test/test_max',$_SESSION);
// here is my problem, $_SESSION is empty, :(
$this->json = isset($_SESSION['json']) ? $_SESSION['json'] : null;
global $gConfig;
if ($gConfig['soapDebug'])
msqLogFile("fwf/post", Array('post' => 'Request: '.$this->json));
$this->response = $this->getResponse();
echo $this->response;
}
....
從mysite.com/ctlClient/index.php
我看到$ _SESSION有數據 但在/fwf/online/index.php
其空。
有人能告訴我我錯過了什麼?
謝謝
[編輯] 從@ RR-
我印這兩個會話ID並獲得差異:
"2013-07-05 09:44:31","Session ID: ihpfs1skrp792gncgancb02516"
"2013-07-05 09:44:31","Session ID: tp6ejtl1tj9bigrgsi3jt6h9a1"
爲什麼它的發生?
[修復]
問候@rr-
答案我發現這個問題,
我需要添加-b
給我的腳本,使餅乾。默認情況下,CURL不會使用它們,並導致會話ID問題。
謝謝rr-
你「在session_start」中的重定向到網頁? – Paul
你確定你正在重定向到完全相同的域名(沒有'www.domain.com'與'domain.com')嗎? –
@Paul是的,我試圖添加它,但仍然無法正常工作。我編輯了mt後 –