Yii Framework Forum: Controlling Sessions Where? Controller Or Views? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Controlling Sessions Where? Controller Or Views? Rate Topic: -----

#1 User is offline   netseeker 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 18-November 12

Posted 18 November 2012 - 08:25 PM

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.
0

#2 User is offline   Aneesh Asokan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 237
  • Joined: 26-September 12

Posted 18 November 2012 - 10:51 PM

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.
Thanks
Aneesh.
0

#3 User is offline   Ujjwal Prajapati 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 47
  • Joined: 24-April 12

Posted 19 November 2012 - 05:02 AM

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users