如何将session设置为函数需要将header存储到函数中

时间:2015-02-04 10:26:13

标签: php

session_start();

function refresh(){

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

}

我想在会话中存储标题功能如何存储

1 个答案:

答案 0 :(得分:2)

尝试这样做:

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之间没有空格