我使用以下方法来消除多个步骤的会话,甚至是单独的变量。
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);
?>
我已经执行 avar_dump ($ _ SESSION);和 aprint_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" }
开心每一天1111