
Question:
I'm currently writing a site built in PHP using Parse.com to store the site's data. I've used parse in several projects before and some of the features fit extremely well. I've now run into an issue where a logged in user can't be detected properly.
<?php
use Parse\ParseClient;
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseGeoPoint;
use Parse\ParseUser;
ParseClient::initialize('Omitted', 'Omitted', 'Omitted');
(... truncated)
function get_user(){
//BROKEN.
//TODO: Fix
$currentUser = ParseUser::getCurrentUser();
if ($currentUser) {
return $currentUser->getObjectId();
} else {
return false;
}
}
(... truncated)
?>
This code is only marginally modified from that in the PHP examples given by parse, but seems to return false no matter what the state of "Logged In"
Session start is called to ensure the session is running, and calling print_r($_SESSION)
outputs a dump which includes the relevant user object.
I understand it's likely something silly that I've missed, but any pointers in the right direction would be much appreciated.
Answer1:For reference here - I was using a dedicated windows server that was configured in a somewhat non-standard way. We've since migrated from the windows server, because Windows - and also a barrage of unrelated issues meant it was just easier to use CentOS instead.
This problem was solved by explicitly calling parse's session storage setter - ParseClient::setStorage( new ParseSessionStorage() );
This was unexpected as the $_SESSION
global did contain the relevant info - but parse wouldn't pick this up until the session storage was set.