This question already has answers here:
Answer
Solution:
Session start should always be at the very top of every page.
Change your code from
<?php
include 'api.php';
session_start();
$msg = "";
to
<?php
session_start();
include 'api.php';
$msg = "";
Also, note that you cannot initialize session twice in one page/file.
other point to look into, when you assign value into session it should be like this:
$_SESSION['email'] = $emailDataFromSomewhere;
To display the value you have to echo like this
echo $_SESSION['email']
To validation if your session initialized or your assigned value is as per desire, use the print_r() function to see all session data
print_r($_SESSION)
Source