How is the chat system implemented? Is it something you can embed in another web page? If so then I recommend creating a page node in XenForo. Page nodes let you access vars like {$visitor.username} in the template which should be useful here.
Kotomi is another option for creating XenForo-integrated pages:
if($.getCookie('cookieName') == false)
{
//Date Expiratation
var expires = 90; // number of days
expires = new Date(new Date().getTime() + expires * 86400000); // milliseconds in a day
$.setCookie(cname, 'cookieName', expires);
}