我看到一些奇怪的行为:
我有 2 个会话,我设置了一些值:$_SESSION['shippingZip']
和$_SESSION['shippingOption']
.
然后我的代码通过此代码发布以表单形式发送的输入值:
$shippingOption = $_POST['shippingOption'];
Print_r ($_SESSION);
$shippingZip = $_POST['shippingZip'];
这些 POST 在此通道中将变为空。但是,当它应该显示之前分配给它的字符串时,打印显示我的会话 $_SESSION['shippingOption'] 为空。-------------------------- POSTING FULL PROOF 会话加载了一些数据:
$_SESSION['shippingOption'] = $shippingOption;
$_SESSION['shippingZip']= $shippingZip;
然后:
Print_r ($_SESSION);
$shippingOption = $_POST['shippingOption'];
Print_r ($_SESSION);
$shippingZip = $_POST['shippingZip'];
Print_r ($_SESSION);
输出:
Array ( [itemAdded] => 1 [Payment_Amount] => 46.52 [cart] => Array ( [4] => Array ( [itemId] => 4 [qty] => 1 ) ) [shippingOption] => FIRST CLASS [shippingZip] => 10025 [shippingPrice] => 1.52 )
Array ( [itemAdded] => 1 [Payment_Amount] => 46.52 [cart] => Array ( [4] => Array ( [itemId] => 4 [qty] => 1 ) ) [shippingOption] => [shippingZip] => 10025 [shippingPrice] => 1.52 )
Array ( [itemAdded] => 1 [Payment_Amount] => 46.52 [cart] => Array ( [4] => Array ( [itemId] => 4 [qty] => 1 ) ) [shippingOption] => [shippingZip] => [shippingPrice] => 1.52
您可以清楚地看到在每次 POST 之后,同名的 SESSION 是如何失去其价值的。简直太疯狂了!!!