New parse.com php API - currentUser does not return user

I can login with user credentials using

try { $user = ParseUser::logIn("myname", "mypass"); // Do stuff after successful login. } catch (ParseException $error) { // The login failed. Check error to see why. } 

but if I try to get currentUser after

 $currentUser = ParseUser::getCurrentUser(); if ($currentUser) { // do stuff with the user } else { // show the signup or login page } 

$ currentUser is not installed.

I suspect this is more likely a php issue that I don't know about. I am grateful for any hint that keepUser is saved in my code until I log out.

+6
source share
1 answer

To work with the getCurrentUser () method, you must determine 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 ); 
+16
source

Source: https://habr.com/ru/post/973919/


All Articles