2014-04-02 53 views
0

一個月前,我的會話沒有保留我自己的網頁之間的值,所以通過更改文件類型從UTF-8UTF8-沒有BOM我的問題解決了。 現在我正在使用銀行網絡服務,我成功地調用了它的方法。通過發佈表單將我的網頁重定向到銀行頁面,付款後重定向到我的網站,我的會話數組爲空!爲什麼我的會話在重定向後不工作?

我的會議不保留其價值......爲什麼?

之前重定向(process1.php):

<?php 
session_start(); // first line and without space 
?> 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="UTF-8"/> 
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">  
     </script> 
     <script> 
      $(document).ready(function(){ 
       $("form").submit(); 
      }); 
     </script> 
    </head> 
    <body> 
     <?php 
      $_SESSION['price']=1000; 
      $_SESSION['username']="14276912"; 
      $_SESSION['password']="874593a"; 
      $_SESSION['ReturnURL']="www.mysite.com/process3.php"; 
      $params=array(//parameters); 
      $client=new SoapClient("https://bankname.com/MerchantUtility.asmx?wsdl"); 
      $result=$client->__soapCall('bpPayRequest', array($params));          
      $RefId=$result[0]; 
     ?> 
     <form method="post" action="https://bankname.com/pgwchannel/startpay"> 
      <input name="RefId" value="<?php echo $RefId?>" type="hidden"/> 
     </form> 
    </body> 
</html> 

從重定向頁面復出(process2.php)後:

<?php 
session_start(); // first line and without space 
var_dump($_SESSION); 
?> 

的var_dump顯示陣列(0){} 我很困惑。

+0

你提交到其他頁面? –

+0

是我從** process2.php **將表格發佈到銀行的gatway,所以process2.php重定向到銀行的付款頁面。在銀行方面的付款操作之後,銀行將結果發佈到我的** process3.php **並重定向到它。 – Javid

回答

0

這是我嘗試使用localhost及其工作。這是簡單的值傳遞代碼。

這是第一頁:

<?php 
session_start(); 
      $_SESSION['price']=1000; 
      $_SESSION['username']="14276912"; 
      $_SESSION['password']="874593a"; 
?> 

<form method="post" action="a.php"> 
      <input name="submit" value="Submit" type="submit"/> 
     </form> 

這是針對網頁:

<?php 
session_start(); 
var_dump($_SESSION); 
?> 

,這是結果:

array(3) { ["price"]=> int(1000) ["username"]=> string(8) "14276912" ["password"]=> string(7) "874593a" } 
+0

謝謝,是的這些代碼正確地傳遞會話的價值,但.. – Javid

+0

你會得到什麼問題? –