Clear sessions containing certain string using PHP

January 24, 2024


function clear_sessions( $input ) {

if ( empty($input) ) {
// do nothing

} else {

foreach ( $_SESSION as $_SESSION_key => $_SESSION_value ) {

if ( strpos($_SESSION_key, $input) !== FALSE ) {
unset( $_SESSION[$_SESSION_key] );
}

}
}
}


Comments

There are no comments.


Comment on this Article

Your email address will never be published. Comments are usually approved within an hour or two. (to prevent spam)