anomaly behavior with session

Hi all,

I have some problems with sessions and a little help would make me happy.

I configure session in config/main/components like:

'session' => array(

            'class' => 'system.web.CDbHttpSession',

            'sessionName' => 'sessid',

            'connectionID' => 'db',

            'sessionTableName' => 'session',

            'autoCreateSessionTable' => true,

            'cookieMode' => 'only'


I work with 2 lists using CListView in first list. Idea is when I take 10 elements from first list and I put them in second list trigger update first list for new elements. Before ajax update I sent a post with id of elements from second list for exclude them from first list.

Code look like this:


            $this->widget('zii.widgets.CListView', array(

                'dataProvider' => $model->search(),

                'itemView' => '_element',

                'ajaxUpdate' => true,

                'enablePagination' => true,

                'id' => 'list1',

                'itemsTagName' => 'ul',

                'beforeAjaxUpdate' => 'js:function(id, data){

                        var exclude = $(".list2 :input").serializeArray();

                        if(exclude.length > 0){

                            exclude.push({name: "' . Yii::app()->request->csrfTokenName . '", value: "' . Yii::app()->request->csrfToken . '"});

                            $.post("' . Yii::app()->createUrl("/test/exclude") . '", exclude);





Code above sent an array with ids of elements from list2 to test/exclude action:

 public function actionExclude() {

        if (isset($_POST['Test']['elements'])) {

            $elements_ids = $_POST['Test']['elements'];

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


            $session->add('exclude', array_unique($elements_ids));



Session "exclude" is used on another action "test/create", interesting part is

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


            if ($session->contains('exclude')) {

                $exclude = $session["exclude"];

            if(count($this->exclude) > 0)

                $criteria->addNotInCondition('id', $exclude, 'AND');


Strange behavior is that after action "test/exclude", session is set every time with correct ids for exclude, but in action "test/create" session random read.

Someting like 1 of 5 updates store correct ids to be excluded (in session), but totally random. Why session doesn’t store data every time?

Any help is a appreciated.