Updating php values using jquery

If you are using sessions, you will need an ajax call that will call a php file within the session that will update a particular session variable. The issue at hand though is that it would not be an update until the next time the base page was loaded since that information would need to be accessed.

In your sample, you will need the page to say:


and then something like:

$date = isset($_SESSION["date"]) ? $_SESSION["date"] : "2016-01-01";

and then on the front end you will need to do an ajax post request to the a file with the data key being “date”:

$_SESSION["date"] = $_POST["date"];

then each time you load the page, as long as session is maintained it will keep up with a date, with the default value being: "2016-01-01"

Browse More Popular Posts

Leave a Comment