Remzo
Remzo

Reputation: 103

PHP Sessions and Parse

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"];}
    ?>

Upvotes: 1

Views: 499

Answers (2)

Remzo
Remzo

Reputation: 103

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

Upvotes: 0

Paras
Paras

Reputation: 9465

After calling the initialize method, add the following:

ParseClient::setStorage( new ParseSessionStorage() );

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

Upvotes: 1

Related Questions