1 回答

TA貢獻1966條經(jīng)驗 獲得超4個贊
你只需要start_session,你不需要覆蓋或銷毀它。
也許我沒有正確理解這個問題,但是當您執(zhí)行start_session() 時,您可以通過啟動新會話或恢復(fù)現(xiàn)有會話來啟用當前 php 腳本中的會話。我認為就您而言,這就是您所需要的。參考:PHP - session_start
另外,我認為覆蓋會話是不好的做法,您也可以刪除您不打算刪除的內(nèi)容。如果你想重置你的變量,我建議你將它們存儲到一個數(shù)組中,比如
$_SESSION['form']['email']
然后如果你想重置 make
$_SESSION['form'] = array();
我認為如果你制作這樣的結(jié)構(gòu),你可以做得更好:
function is_first_step_completed() // checks if the first step fields are filled or not
function is_second_step_completed() // checks if the second step has all fields completed
if (!is_first_step_completed()) {
// show first step
}
而不是存儲變量 is_first_step_completed。如果您使用這樣的變量,則需要始終將其設(shè)為真或假。
- 1 回答
- 0 關(guān)注
- 150 瀏覽
添加回答
舉報