title: Create constructor method in controller in Yii
body: <p>I have just started to learn <code>Yii</code>, where I have created one <code>PostController</code> Controller. In this controller I am having one requirement of using <code>Sessions</code>.</p>
  
  <p>So I have created one constructor method and its code is as follows</p>
  
  <pre><code>public $session;
  public function __construct() {
      $this-&gt;session = new CHttpSession;
      $this-&gt;session-&gt;open();
  }
  </code></pre>
  
  <p>But after creating this constructor the controller was not working and gives error. And after deleting this code my controller was working perfectly. I have written this code inside constructor to not initialize the <code>Session</code> in each method for <code>actionCreate</code> and <code>actionUpdate</code>.</p>
  
  <p>So my question is how can we create constructor in <code>Yii</code>?</p>
  
  <p>Thanks</p>