I have set a session on a page, but it does not work when it calls on another page. I have tried all possible fixes, but they don't work. I don't know where I am going wrong.
Here is my sample code.
page1.php:
<?PHP
$_SESSION['msg'] = "This is a test message";
?>
But when it calls on another page, this is not working
<?PHP
echo $_SESSION['msg'];
?>
Can someone help me to fix this?
The inbuilt PHP function session_start() needs to be defined at the top of the page. A session is started with session_start() at the top.