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?
php session
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.
Test your knowledge with interactive quizzes.
Prepare for interviews with curated question sets.
Ask your coding-related doubts and get answers.
Earn certifications to enhance your resume.
Hands-on projects to improve your skills.
Test your knowledge with interactive quizzes.
Prepare for interviews with curated question sets.
Add your technical blogs and read technical topics.
Earn certifications to enhance your resume.
Hands-on projects to improve your skills.