On my page, users have the option to select a client. When they select one, this selection will be set in $_SESSION['selectedClient']
. A user may then choose to pick a different client which would have to overwrite the current $_SESSION['selectedClient']
. So when I try to update $_SESSION['selectedClient']
it will show me that the session variable has updated. But when I reload the page it will show the previous/first selected client.
Here is the piece of code I currently have to try this:
if($_POST['clientEmail']){
$_SESSION['selectedClient'] = $_POST['clientEmail'];
echo '<script>document.location=\'\?p=home\';</script>';
}
The echo leads to the same PHP file in which I set session var and try to update the session var, which is needed in this case.
I've tried to unset $_SESSION['selectedClient']
before assigning a new post like:
if($_POST['clientEmail']){
unset($_SESSION['selectedClient']);
$_SESSION['selectedClient'] = $_POST['clientEmail'];
echo '<script>document.location=\'\?p=home\';</script>';
}
I haven't been able to find anything on google that could help me, which is why I decided to make a SO account and ask here. Feel free to ask if more information is needed.
EDIT:
When $_SESSION['selectedClient']
is set and I select a new client, the post contains the newly selected value/client. After refresh, post is empty and session is reverted back to the client which was selected before.
selecting new client:
_POST['clientEmail'] = >lol@lol.com<
_SESSION['selectedClient'] = >lol@lol.com<
after refresh:
_POST['clientEmail'] = ><
_SESSION['selectedClient'] = >login@login.com<