Unset all session variables with similar name

后端 未结 4 848
生来不讨喜
生来不讨喜 2021-01-24 08:55

I\'m using some $_SESSION variables for filtering many query records that have a similar name (ex. $_SESSION[\'nameFilter\'] or $_SESSION[\'cityF

4条回答
  •  -上瘾入骨i
    2021-01-24 09:48

    You need to check for every exist session and check it name. Please check below example code.

     $sessValue){
        //Check for session name exist with 'filter' text...
        if (strpos($sessKey, 'filter') !== false) {
            unset($_SESSION[$sessKey]);//Unset session
        }
    }
    
    echo '
    ' . print_r($_SESSION, TRUE) . '
    '; /*Output... Array ( [fourtilter] => four ) */ ?>

    May this help you well.

提交回复
热议问题