質問

I was trying to minimize the db hits by storing data in session when the session starts and then return the data from the session for the subsequent requests. But It looks like it is not working as I expected

See test remote method below

update: added session_start() which I missed to copy

Main.php - Service class

class Main{
      public function amfRequest(){
         session_start();
         $test = new Test();
         return $test->testSession();
      }
  }

Test.php

class Test(){
     public function testSession(){
     if (!isset($_SESSION['test'])){
        return "setting sesion variable";
        $_SESSION['test'] = "all set!";
    }else{
        return "getting session variable";
           }                
      }

}

Expected result

  • 1st run - return setting sesion variable
  • subsequent runs - return getting session variable

But it is always returns setting sesion variable

Does AMF PHP destroys the session every time I request? if so, how to handle sessions then?

役に立ちましたか?

解決

Answer is NO. The results I was getting because the session was destroyed somewhere else in the code, thus I was always getting isset($_SESSION['test']) as false.

他のヒント

Basic codding info. Workflow breaks in return. so $_SESSION['test'] = "all set!"; newer gets call.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top