I'm using the Parse.com PHP SDK on one of my pages. I seem to have a similar problem I faced on the iOS version but I easily solved that using the 'fetch' command.
The problem is when I edit information in my database, it does not update on my web page when I refresh the page. The user has to log out then log back in for the new data to be shown.
Here is how I'm getting the data:
<?php $u1=ParseUser::getCurrentUser()->get("auto"); echo $u1; ?>
Here is the documentation on the 'fetch' command but I don't understand how it works or how it is implemented: http://parseplatform.org/parse-php-sdk/classes/Parse.ParseUser.html#method_fetch
Does anyone know how to show the updated string values using this command or anything similar that would work?
The issue you're seeing is a cached object in your current session, specifically the current ParseUser
. You can see that the php sdk attempts to find the current user from a variety of places, all effectively independent of the server-side copy.
You were in the right direction, you can use the fetch
method to 'refresh' any ParseObject
by updating it with any new changes from the database:
// get the current user
$user = ParseUser::getCurrentUser();
// fetch changes from parse
$user->fetch();
// get your newly set key/value pair
$isAuto = $user->get('auto');
Your user object will then be refreshed with the changes you need.