0

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.

Sean Leach
  • 49
  • 6
  • Sounds like the currentUser hasn't been logged in. Are you calling the appropriate signUp or login? – Dehli Sep 22 '14 at 15:56
  • Yes, Calling either signUp or logIn returns successfully, creates a user where relevant but the login seems not to persist. As mentioned above, dumping the $_SESSION "Superglobal" contains the logged in user's details, but ParseUser::getCurrentUser() returns false no matter what. Rather confusing me! – Sean Leach Sep 23 '14 at 08:02

1 Answers1

0

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.

Sean Leach
  • 49
  • 6