I have a global variable called $_SESSION['user_name']
which is set with POST value when I click on the Submit button in a form.
In this php file, I check if $_SESSION['user_name']
is empty.
If yes, I have to file a form and if no, means the session is still going on and it sends you to the profile.
Anyway, after I fill the form, then it compares this variable if it matches another variable and then heads to the profile.php if true.
On this page, I have one button which is meant to "logout" the user.
On pressing, it sends you to another php file where I change the variable (I have echo-ed it before and it does change it)
but it doesn't forward it back to main page (index.php) and the variable still has the value from the $_POST although it is different in logout.php as I change it.
Code I have at logout.php
:
<?php
session_start();
$_SESSION['user_name'] = ""; // makes it empty
echo $_SESSION['user_name'];
?>
And some html where I use meta tag to redirect back to the index.
Now, my question is, how can I forward the changed variable back to the index or form page? Or is there any other way of doing that?
Thanks :)