text field and session variable

I want to do a text field to store a session variable to filter something.How to do that?

No one?

I dont know if i explained it well but what I want to do is through an input store a value in a session variable

Hi,

Not clear your requirement. But this is how you store and retrieve data from session.

Storing in a session


Yii::app()->user->setState(‘text_input’, $_POST[‘text_input’]);

Retreive


Yii::app()->user->getState(‘text_input’);

Thanks

Aruna

Ok but what i want to know is what is the best yii widget to get the value.Now i have made a simple html input text with ajax like this:




<div id="search">

        <input id="song" type="text" />

        <?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl.'/images/Search.png'),

                '#',

                array(

                     'style'=>'vertical-align:top',

                     'ajax' => array(

                            'type' => 'GET', 

                            'url' => CController::createUrl('index'),

                            'update' => '#conteudo', 

                            'data' => array('song' => 'js: $("#song").val()')

                            )

        ));?>

    </div>



May be stateful form will help you? (http://www.yiiframework.com/doc/api/1.1/CActiveForm#stateful-detail)

Any example code?




   // inside your Controller

   ...


    public function actionIndex()

    {

        if(isset($_POST['song'])) {

            $song=$_POST['song'];

            Yii::app()->user->setState('song', $song); // save $song in session

        }

    }

About stateful form