-2

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?

4

1 回答 1

0

Something is output before you call that function, check especially for blank non-PHP lines. Without more info or code, that's all I can suggest.

于 2013-01-09T00:17:17.713 回答