'I have a session variable in the navbar that displays correctly until that variable is updated in mysql
I have the following in my navbar and is displaying the correct value, until the value is changed in mysql. To display it correctly, I have to clear the session:
<a style="margin:10px;background-color:#EEA45A;border-radius:25px;padding:10px;" href="avail/index.php" class="true_home"><?php echo htmlspecialchars($_SESSION["availability"]); ?></a>
When the availability of the user is changed from Available to Unavailable, the session variable displays the value when the form is loaded.
Does anyone know if the session variable availability could be changed dynamically so the session does not have to end or the user does not have to log out? Refreshing the page does not refresh this.
Thank you in advance.
Solution 1:[1]
In case this helps anyone, this is what I did:
Per ADyson's suggestion, I removed the session for the availability field and used the following query for the currently-logged in user, since the username is a session variable:
SELECT * FROM `users` WHERE username = '" . $_SESSION['username'] . "'
Then, I just echoed the following:
<?php echo $row['availability']; ?>
The availability value for the logged in user now changes and quickly as it's updated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | wilcan |
