如何将会话设置为函数需要将标头存储到函数中


How to set session into function need to store header into function

session_start();
function refresh(){
$_session['refresh'] = header('Refresh: 5, url=https://www.google.com);
}

我想在会话中存储标题函数如何存储

尝试这样做:

function refresh() {
    $_SESSION['refresh'] = array('rate'=>5, 'url'=>'https://www.google.com');
}

// Check if refresh session Exists 
if( isset($_SESSION['refresh']) && count($_SESSION['refresh']) > 0 ) {
    header("Refresh: ".$_SESSION['refresh']['rate'].";url=".$_SESSION['refresh']['url']."");
}

注意:;url 之间没有空格