Why this warning message appaear ?(Cannot regenerate session id - headers already se)

hello,

i programmed a function . and wrote that regenrate session_id by session_regenerate_id() function when user register successfull , but the warning message appear :

Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent

i want know what’s the causes of apearing this message and how to solve it

regardes

there was output (echo, print, etc) before hand.

Once a file outputs anything, even whitespace, headers are sent.

Whenever you send headers don’t echo or print anything to the screen before this.

thanks alot for all , i’am understanded now … i wan’t your opinion in my method to regenrate id when user login it’s account
i put this code in first of each page


<?php
if(isset($_SESSION['username']) && isset($_SESSION['password']))
{
session_regenrate_id();
}
?>

it’s regenrate the session id when user login and visit every page …
what’s your opinion ? is this true method to change session id when user visit every page in script after login ?

Yes, this is a good method. However, why do you change the SID on EACH page?