EDIT
Wordpress sends header info before the header.php file is run. So starting the session in the header.php may still conflict with the header info that wordpress sends. Running it on init avoids that problem. (From jammypeach's comment)
Write the following code in your functions.php file:
function register_my_session()
{
if( !session_id() )
{
session_start();
}
}
add_action('init', 'register_my_session');
Now if you want to set data in session, do like this
$_SESSION['username'] = 'rafi';
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…