I can't start a session in Parse PHP SDK
Get the solution ↓↓↓I'm having problems to start a session in this framework. The "Log In" is working well:
<?php require_once ('vendor/autoload.php'); ?>
<?php
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParseUser;
use Parse\ParseClient;
use Parse\ParseException;
use Parse\ParseFile;
use Parse\ParseSessionStorage;
session_start();
ParseClient::initialize( "D4tClbuaS3OCWzRvQjT2L3vB8KUDJesFvVNbeJke", "P0eODP9cPcFFXOwokl1SRpUbSSjQx1kjO55S1nQ8", "lxmB0b8RhwNa0kneye4qHIEuiZDJR5B4cR8f82Ud" );
// Set individual access rights
// Login
$usuario = filter_var($_POST["usuariolog"], FILTER_SANITIZE_STRING);
$password = filter_var($_POST["passwordlog"], FILTER_SANITIZE_STRING);
try {
$user = ParseUser::logIn($usuario, $password);
} catch(ParseException $ex) {
echo 'Failed to create new object, with error message: ' . $ex-
>getMessage();
}
The problem stars when I open another page where the user needs to be logged in order to display the page. I don't know where is the mistake:
<?php require_once ('vendor/autoload.php'); ?>
<?php
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParseUser;
use Parse\ParseClient;
use Parse\ParseException;
use Parse\ParseFile;
ParseClient::initialize( "D4tClbuaS3OCWzRvQjT2L3vB8KUDJesFvVNbeJke", "P0eODP9cPcFFXOwokl1SRpUbSSjQx1kjO55S1nQ8", "lxmB0b8RhwNa0kneye4qHIEuiZDJR5B4cR8f82Ud" );
?>
<?php session_start(); ?>
$currentUser = ParseUser::getCurrentUser();
echo $currentUser;
if ($currentUser) { ?>
It's ok
<?php
echo "username: ". $currentUser->getObjectId();
} else {
// show the signup or login page
echo "Not Found";
}
?>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: your lock file does not contain a compatible set of packages. please run composer update.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.