New parse.com php API - currentUser not giving back a user

后端 未结 1 1672
梦谈多话
梦谈多话 2020-12-18 04:49

I am able to login with user credentials with

try {
  $user = ParseUser::logIn(\"myname\", \"mypass\");
  // Do stuff after successful login.
} catch (ParseE         


        
相关标签:
1条回答
  • 2020-12-18 05:25

    In order for the getCurrentUser() method to work, you must define the type of session storage to use. You can use the ParseSessionStorage class to achieve this:

    use Parse\ParseClient;
    use Parse\ParseUser;
    use Parse\ParseSessionStorage;
    
    session_start();
    
    // Init parse: app_id, rest_key, master_key
    ParseClient::initialize('xxx', 'yyy', 'zzz');
    
    // set session storage
    ParseClient::setStorage( new ParseSessionStorage() );
    
    try {
      $user = ParseUser::logIn("myname", "mypass");
      // Do stuff after successful login.
    } catch (ParseException $error) {
      // The login failed. Check error to see why.
    }
    
    $currentUser = ParseUser::getCurrentUser();
    
    print_r( $currentUser );
    
    0 讨论(0)
提交回复
热议问题