php - Sessions is not performing the task
Get the solution ↓↓↓function display_message()
{
if (isset($_SESSION['message'])) {
echo $_SESSION['message'];
unset($_SESSION['message']);
}
}
Why when I remove the unset the code work but the problem that the message is not removed , so I need to keep can anyone tell me why the code is not work
Note
That i use session_start()Answer
Solution:
I have faced that issue before but i fixed it in this way and tested it working in local environment
function display_message()
{
if (isset($_SESSION['message'])) {
echo $_SESSION['message'];
}
unset($_SESSION['message']);
}
Instead of using unset function inside if statement, move it to outside.
Answer
Solution:
You can unset instead,destroy your session whit down code. The purpose is the name session.
session_start();
$_SESSION['name'] = "name";
echo "<br>" . $_SESSION['name'] . "<br>";
$_SESSION['family'] = "family";
$_SESSION['name'] = null;
test the code
Answer
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.