mardi 29 décembre 2015

How to handle sessions in Laravel 5 with the Parse SDK?

I'm building an app using the Parse PHP SDK in Laravel 5 (I use "Laravel-Parse" by Graham Campbell for the Parse SDK integration).

I am able to create a user with this code :

$user = new ParseUser();
$user->setUsername($username);
$user->setEmail($email);
$user->setPassword($password);

try {
    $user->signUp();
} catch (ParseException $ex) {
    // error in $ex->getMessage();
}

... then I can log-in :

try {
    $user = ParseUser::logIn($username, $password);
} catch(ParseException $ex) {
    // error in $ex->getMessage();
}

and just after this code, I can get the current user from Parse :

$user = ParseUser::getCurrentUser();

The "getCurrentUser()" function returns the current user if I execute this code just after the Parse login function. However, if I go to another page in my Laravel website, and try to get the current user again with the same code, I get an empty array.

I guess it is a session error, can you tell me if I missed anything ? Or how to fix that ?

Thanks.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/22xYfKM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire