Hosting CometChat on a separate server/sub-domain

CometChat has full cross-domain support. You can run CometChat on a separate server, domain/sub-domain. Note, some plugins like page translation may not work when used in cross-domain environment.

An ideal use of this feature is when you want to load CometChat on a separate server e.g. chat.yoursite.com and want to use CometChat on www.yoursite.com.

Perform the following steps:

* Upload and configure CometChat on your sub-domain following the standard installation instructions.

* Edit cometchat/config.php and set BASE_URL to the full path e.g. http://chat.yoursite.com/cometchat/
* Then set CROSS_DOMAIN to 1 and set CC_SITE_URL to your site’s URL e.g. http://www.yoursite.com/.

crossdomainsetup
* Add the following code to the site template (remember to include the full URL path).

Add the code immediately after <head> tag:

<script>
var userid = 'USERID'; // Must be populated programmatically
document.cookie = "cc_data="+userid;
</script>
<link type="text/css" rel="stylesheet" media="all" href="http://chat.yoursite.com/cometchat/cometchatcss.php" /> 
<script type="text/javascript" src="http://chat.yoursite.com/cometchat/cometchatjs.php" charset="utf-8"></script>

Use of CometService or alternatives is strongly recommended when using CometChat in cross-domain environment. This guide will work for custom coded sites only.

Not finding what you need?

The CometChat team is here to help!