1

I've a few php files that need to access the Parse backend. I don't know how to connect them. In my previous question the answer was: SESSIONS!

Now i've a new problem:

If i comment out session_start(), i've access to the Parse database, but not to the session variables.

If i uncomment session_start(), i've access to Session variables, but not to Parse anymore.

Why is that?

 <?PHP
    //session_start();


    echo "I'm in PHP!!!";

      require 'vendor/autoload.php';

      use Parse\ParseException;
      use Parse\ParseClient;
      use Parse\ParseQuery;
      use Parse\ParseUser;

      ParseClient::initialize('xxxxx', 'xxxxx', 'xxxxx');
      ParseClient::setServerURL('https://xxxxxx');



     //if (isset($_SESSION["currentUser"])){
       $query = new ParseQuery("CourseInfo");   
       $query -> equalTo ("CourseID", "Demo2");
       $results = $query->find(); 
       echo "Successfully retrieved " . count($results) . " scores.";
    // }


    echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>";  // just to test 
    if (isset($_SESSION["currentUser"])) {echo $_SESSION["currentUser"];}
    ?>
0

2 Answers 2

1

After calling the initialize method, add the following:

ParseClient::setStorage( new ParseSessionStorage() );

Also checkout: http://parseplatform.github.io/docs/php/guide/#session-storage-interface

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Paras, that might be a good solution, but i don't understand the Guide very well (PHP beginner problem) Is there a way that my existing code can work? Do you know what could be the problem?
0

I think your answer is right, a somewhat more detailed explanation is here:

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

Tx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.