<?php

/**
 * 
 * @author p6
 * @property Session model
  */
class CurrentSession extends CApplicationComponent
{

  public function getModel()
  {
    //I cannot cache sessionModel because sessionId could be
    //regenerated in anytime during the request

    $sessionId = Yii::app()->session->sessionId;
    $sessionModel = Session::model()->findByPk($sessionId);
    if ($sessionModel === null)
      throw new CException(Yii::t('app', 'Cannot find a session model given his id.'));
    return $sessionModel;
  }
}
