First of all: This question is not a duplicate, don't close this like my previous question. I've looked at most questions about sessions.
In this case I am looking to update $_SESSION['selectedClient']
while remaining on the same page.
A user can choose a client, this client will be stored in $_SESSION['selectedClient']
. At some point a user may want to select another client. So for that, I've tried this:
if(isset($_POST['clientEmail'])){
$_SESSION['selectedClient'] = $_POST['clientEmail'];
}
Except this doesnt work. This would set the initial selected client and should also update a next selection.
If you have selected the first client and you're trying to select a new client. These are the outputs:
_POST['clientEmail'] = >lol@lol.com<
_SESSION['selectedClient'] = >lol@lol.com<
after refresh:
_POST['clientEmail'] = ><
_SESSION['selectedClient'] = >login@login.com<
Clarification: login@login.com is the first selected client. lol@lol.com new selected client.
Note 1: session_start()
has been set.
Note 2: tried unsetting $_SESSION['selectedClient']
and then assigning the new post.
Note 3: How to use store and use session variables across pages? Doesnt have the answer I am looking for, been on this question multiple times.