Session data automatically gets cleared

Hi,

i am a newbie to yii2.

i have made a code which stores subcategory in session temporarily before the query is executed but for some reason the session gets cleared automatically just after setting it.




$session = yii::$app->session;

if (!isset($session['subCategory']) || count($session['subCategory']) === 0) {

      $session->set('subCategory', array($category));

}

Hi vishal, welcome to the forum.

How did you know the session got cleared?