PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
it repopulates the objects data ('by reference') and I was thinking that it would modify the values, but it doesn't - since its an object in the session I have to log out, and back in for it to show up as changed.. any ideas as to why?
Thanks in advance!
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: Posting Code in the Forums to learn how to do it too.
$authenticatedUser = $_SESSION['authenticatedUser'];
$locationDS = new LocationDataSource();
$locationDS->updateLocation($_POST, $authenticatedUser->location);
$_SESSION['authenticatedUser'] = $authenticatedUser;
// but since $authenticatedUser is a copy of another variable
$authenticatedUser =& $_SESSION['authenticatedUser']; // by reference
$locationDS = new LocationDataSource();
$locationDS->updateLocation($_POST, $authenticatedUser->location);
// no saving necessary
// but that's still more work than necessary: just use $_SESSION[authenticatedUser] directly
$locationDS = new LocationDataSource();
$locationDS->updateLocation($_POST, $_SESSION['authenticatedUser']->location);
tasairis I tried your last solution before I posted, and found that the unserialize was necessary.. if I do what you suggested last I get null back for the location object, where as if I unserialize it I get the object just fine (so its not that the object inst loaded properly).
This was the case with all objects in the session, location is an object, of the user object - so because of this I added the serialize/unserialize and things began to work.
I have also tried the solution second on your list with no luck.. nothing seems to be saving, or updating by reference correctly..
Yes, I tried them all with no success.. I am currently having to reload the user object every time the page loads, and reassign to the session obj.. which is obviously not desirable.