Session timing out for no reason

Ok, so this is very weird. I have not encountered anything like this before and I have no idea why this is happening.

I have an AJAX controller action that looks like this…




    /**

     * Action performed when a calendar event is clicked.

     * @return mixed

     */

    public function actionWizardUpdateClickEvent()

    {       

        //get the event id

        $eventId = (int)Yii::$app->request->get('eventId');

        

        //open session

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

        if(!$session->isActive)

            $session->open();


        //get the events from session

        $events = $session->get('events');


        //get the event being viewed

        $event = $events[$eventId];


        //check if there is a conflict. If so, get the conflict message

        $conflictMessages = [];

        $facilities = $event->facilities;

                

       if(is_array($facilities))

        {

            foreach($facilities as $facility_id)

            {

                $facility = \common\models\Facility::findOne($facility_id);

                if(isSet($facility))

                {

                    if(!$facility->checkSchedule($event->start, $event->end))

                    {

                       $conflictMessages[] = 'conflict error';

                    }

                }

            }

        }


        return $this->renderAjax('/course/wizard/update/step_two/test', [

            'event' => $event,

            'conflictMessages' => $conflictMessages,

        ]);

    }



I have almost the exact same code working fine on another page with no problems but for some reason when I call this action it takes five+ minutes to load the page. The weird thing is that if I comment out the “return $this->renderAjax” part it loads fine, within a second or two. I can’t figure out for the life of me why the page load time jumps to five minutes when I add the ‘$this->renderAjax’ part. Also, If I comment out all the code and just leave the ‘$this->renderAjax’ part it also loads fine. It only causes a problem when they are both together.

I initially thought that the problem is with the view file itself. As stated in the code above, the action is rendering the “/course/wizard/update/step_two/test” page which is completely empty so I don’t see how that would effect anything. Does anyone know why this might be happening? I’m wondering if maybe PHP is running out of memory.

When the renderAjax part is enabled the problem starts when I call "$session->open()". when this is called it lags like crazy.