php – session_regenerate_id(): Cannot regenerate session id – headers already sent in

exception or error:

it is outputting: session_regenerate_id(): Cannot regenerate session id – headers already sent in

session_start();

session_regenerate_id();
$_SESSION['inside'] = TRUE;
$_SESSION['username'] = $GettedName;
$_SESSION['id'] = $ID;
$_SESSION['email'] = $sirname ;
$_SESSION['sirname '] = $sirname ;
How to solve:

There are few reason for session already send error. Please trey with ob_start();

ob_start();
session_start();
session_regenerate_id();
$_SESSION['inside'] = TRUE;
$_SESSION['username'] = $GettedName;
$_SESSION['id'] = $ID;
$_SESSION['email'] = $sirname;
$_SESSION['sirname '] = $sirname;

###

ob_clean();
ob_start();

at the start of the code and check you have space in your session array like below

$_SESSION['sirname '] = $sirname ;

should be

$_SESSION['sirname'] = $sirname ;

and try this

ob_clean();
ob_start();
session_regenerate_id();
$_SESSION['inside'] = TRUE;
$_SESSION['username'] = $GettedName;
$_SESSION['id'] = $ID;
$_SESSION['email'] = $sirname;
$_SESSION['sirname'] = $sirname;

Leave a Reply

Your email address will not be published. Required fields are marked *