Cancel the creation of user sessions in Yii 1.x for some site requests?



  • Mobile application makes Ajax requests to the site Yii 1.x. In Yii, a new user session starts for each such request, because the mobile application cannot store COOKIE for PHPSESSID website.

    How do you not start the Yii mobile application? I know how to determine exactly the requests from the mobile application. It is the question of stopping the meeting mechanism!

    By the way, the sessions are stored in the OBD system, such as:

    'session' => array(
        'timeout' => 32400, // 9 часов
        'class' => 'system.web.CDbHttpSession',
        'connectionID' => 'db',
        'sessionTableName' => 'session',
    ),
    


  • Reclassify the class and turn off http://www.yiiframework.com/doc/api/1.1/CHttpSession#autoStart-detail of the session, provided that:

    class DbHttpSession extends CDbHttpSession{
    
    public function init()
    {
        if($this->isMobile()){
            $this->autoStart = false;
        }
        parent::init();
    }
    
    public function isMobile(){
        //...
        return true;
    }
    
    //...
    

    }

    Indicate your class in the configuration file:

    'session' => array(
    'class' => 'application.components.DbHttpSession',
    //...
    ),




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2