我使用以下方法消除了多个步骤的执行,甚至消除了单独的变量。
if($payment === 'Completed'){
session_start();
unset($_SESSION['datos_form']);
unset($_SESSION['__step__']);
unset($_SESSION['formid']);
unset($_SESSION['sPaso']);
unset($_SESSION['Pending']);
unset($_SESSION['p']);
unset($_SESSION['step']);
unset($step);
}
但是使用unset
函数并不能消除这些步骤
我保存步骤的PHP文件
<?php
session_start();
$step = isset($_GET['step']) ? $_GET['step'] : 1;
$_SESSION['datos_form'] = $_POST;
$datosForm = (isset($_SESSION['datos_form']) && is_array($_SESSION['datos_form'])) ? $_SESSION['datos_form'] :array();
$sPaso = isset($datosForm['__step__']) ? $datosForm['__step__'] : 1;
$step = isset($step) ? $step : $sPaso;
$_SESSION['datos_form']['__step__'] = $step;
header('Content-Type: application/json');
$json = array(
'radio' => $radio,
'step' => $step
);
echo json_encode($json);
?>
我执行了var_dump ($ _ SESSION);
和print_r ($ GLOBALS);
,获得以下信息:
[_SESSION] => Array
(
[datos_form] => Array
(
[__step__] => 3
)
[4b228aaae2a6a7ce403bc4ecbc481de6] => ../libro.pdf
[cart] => Array
(
[0] => 11
)
[qty] => Array
(
[0] => 1
)
[formid] => 64da7c62c643f40684f573acffb144eba6bfaf63
[id_user] => 1
)
)
使用var_dump
:
array(6) { ["datos_form"]=> array(1) { ["__step__"]=> string(1) "3" }
当我转到步骤1时,[__step__] => 1
string(1) "1"
获得了以下更改:
[datos_form] => Array
(
[__step__] => 1
)
array(6) { ["datos_form"]=> array(1) { ["__step__"]=> string(1) "1" }
当我转到步骤2时,[__step__] => 2
string(1) "2"
获得了以下更改:
[datos_form] => Array
(
[__step__] => 2
)
array(6) { ["datos_form"]=> array(1) { ["__step__"]=> string(1) "2" }
答案 0 :(得分:0)
您正在将setState()
设置为__step__
的直接后代,但它是$_SESSION
的子代
要取消设置,您需要$_SESSION[datos_form]