Controlling Sessions Where? Controller Or Views?

Hi there,

I guess I’m going to disappointed by YUM and I have to start to write my own user management,

I want to know which way is much better to control sessions and user’s data ? do I have to control them in controllers or views?

Best.

You can use session like this


 $session=new CHttpSession;

       $session->open();

       $session['session_id']=$model->user_id;

Then the session data can access anywhere in your application by using this


$session=new CHttpSession;

      $session->open();

      $data=$session['session_id'];

The session data avilable in the $data variable.

Although you can write wherever you want; the best place to write would be in the controller and filter any data you need to based on that. Don’t bother to do this in views as it is clearly for presentation only.