evographics
evographics

Reputation: 3

Parse PHP SDK Parse Query with Session Token

I'm building an app using the new Parse PHP SDK. How can in include the user session token inside a ParseQuery?

Upvotes: 0

Views: 1487

Answers (1)

Niraj Shah
Niraj Shah

Reputation: 15457

If you set the ParseSessionStorage in your code, you can make use of the getCurrentUser() method in the SDK.

session_start();

// Init parse: app_id, rest_key, master_key
ParseClient::initialize('xxx', 'yyy', 'zzz');

$storage = new ParseSessionStorage();
ParseClient::setStorage( $storage );

$user = ParseUser::getCurrentUser();

You can then get the session token as follows:

$sessionToken = ParseUser::getCurrentUser()->getSessionToken();

You don't need to pass the session into calls. It will automatically use the session if available.

Upvotes: 3

Related Questions