title: CakePHP: CometChat Integeration
body: <p>i'm implementing <strong>CMR Application</strong> in CakePHP Framework 2x. In that app, i have a requirement of Online text Chat, Audio Chat, screen sharing and Video Chat. After searching quite a time, i have ended up with a decision of using <strong>CometChat 5.0</strong> Platinum Edition. Work Progress:</p>
  
  <ul>
  <li>Placed Cometchat folder in webroot directory.</li>
  <li>Installed it correctly.</li>
  <li>Configured database correctly.</li>
  </ul>
  
  <p>Actually right now i'm facing issues in using it with my Applicaton. For resolving issues i have searched google, but there is not a single place to tell me:</p>
  
  <ul>
  <li>How and Where to use getUserID() or chatLogin() function in CakePHP ?</li>
  <li>Where or What to do with session like: <strong>$_SESSION['basedata'</strong> and <strong>$session['session_auth_user_id']</strong> etc, there are other many sessions variables that have no meaning with my table fields or tables it had created itself.</li>
  </ul>
  
  <p>Right now it is showing chat bar tray correctly but The Error or Alert i have to see all the time is "<strong><em>Please login to use the chat</em></strong>", after analyzing, i came to know that ChometChat should know about logined user information to start but it seems it can only get it through the sessions or somewhere else, that i probably should know. If u think i had any integeration issues, i'm posting some code here, u can see it urself : (integeration.php)</p>
  
  <p>Advanced Settings:</p>
  
  <pre><code>define('SET_SESSION_NAME','');          // Session name
  define('DO_NOT_START_SESSION','1');     // Set to 1 if you have already started the session
  define('DO_NOT_DESTROY_SESSION','0');   // Set to 1 if you do not want to destroy session on logout
  define('SWITCH_ENABLED','1');       
  define('INCLUDE_JQUERY','1');   
  define('FORCE_MAGIC_QUOTES','0');
  </code></pre>
  
  <p>DATABASE Configurations:</p>
  
  <pre><code>define('DB_SERVER',                 'localhost'                     );
  define('DB_PORT',                   "3306"                             );
  define('DB_USERNAME',               'root'                 );
  define('DB_PASSWORD',               ''                 );
  define('DB_NAME',                   'cakechat'                     );
  define('TABLE_PREFIX',              ""                              );
  define('DB_USERTABLE',              "users"                            );
  define('DB_USERTABLE_USERID',       "id"                          );
  define('DB_USERTABLE_NAME',         "username"                 );
  define('DB_AVATARTABLE',            " "                                );
  define('DB_AVATARFIELD',            " CONCAT(".TABLE_PREFIX.DB_USERTABLE.".".DB_USERTABLE_USERID."        ,CONCAT('/',".TABLE_PREFIX.DB_USERTABLE.".user_photo))" );
  define('DB_USERTABLE_LASTACTIVITY', "user_lastactive");
  </code></pre>
  
  <p>Functions 1:</p>
  
  <pre><code>function getUserID() {
      $userid = 0;
  
  if (!empty($_SESSION['basedata']) &amp;&amp; $_SESSION['basedata'] != 'null') {
      $_REQUEST['basedata'] = $_SESSION['basedata'];
  }
  
  if (!empty($_REQUEST['basedata'])) {
      $userid = $_REQUEST['basedata'];
  }
  
  if (!empty($_COOKIE['se_auth_token'])) {
      $sql = ("select session_auth_user_id from ".TABLE_PREFIX."session_auth where session_auth_key = '".mysql_real_escape_string($_COOKIE['se_auth_token'])."'");
      $query = mysql_query($sql);
      $session = mysql_fetch_array($query);
      $userid = $session['session_auth_user_id'];
  }
  
  return $userid;
  </code></pre>
  
  <p>}</p>
  
  <p>My only request: Please share any reference link or walk-through to make things right and functional, any little effort, will be highly appreciated. <strong>Thanks in advance</strong> !</p>