I have the following code in the same file:
add_action( 'init', 'iniciaSessao', 1 );
function iniciaSessao() {
if(!session_id() ) {
session_start();
}
}
function info() {
$_SESSION['nome'] = 'meu nome';
}
info();
//session_regenerate_id(true);
wp_redirect($minhaUrl);
exit();
When you go to the homepage of the site (where you are redirecting) and use print_r($_SESSION['nome']);
, the information set does not appear.
NOTE: The following error message appears when uncommenting session_regenerate
:
session_regenerate_id (): Can not regenerate session id - headers already sent