Possible Duplicate:
Headers already sent by PHP
I have recently shifted to storing sessions in a database. I am trying to set ac cookie in write_function()
, but it results in a PHP error Cannot modify header information - headers already sent. Here's the code:
function write_session($sid, $data)
{
if(empty($data)){ return; }else if(!isset($_COOKIE['crs'])){ setcookie('crs','xrs',0,'/'); }
}
session_set_save_handler('open_session', 'close_session','read_session', 'write_session','destroy_session','clean_session');
How do i correct this?