1
votes

I'm trying to create an online chat program for my web users to speak to a salesperson live. I use an ajax jquery command to refresh the chat, which is stored in a database. The problem I'm running into is it is losing the session variable that identifies the user on the ajax call, but it only seems to do this to some users. Is there some setting for coldfusion that I'm missing?

Should I have any specific settings set in my CF Administrator?

<cfapplication name="Chat Room"
           clientmanagement="Yes"
           sessionmanagement="Yes"
           sessiontimeout="#CreateTimeSpan(0,1,0,0)#" >

<cfset session.UserID = #new_session.UserID# >


 window.onload = function() 
     {
        setInterval("ReloadChatWindow();", 2500);
     }; 

function ReloadChatWindow()
    { 
        $.ajax({url: "messages.cfm", success: function(result){
            $("#ChatLog").html(result);
        }});

        $("#ChatLog").scrollTop($("#ChatLog")[0].scrollHeight);
    }

new_session.UserID# is just from a database insert (the user provides their name and I assign them the userID.

Only one domain uses the session, there are no cross domain calls.

1
where are you getting new_session.UserID and why bother setting a new session scope? - TRose
Try turning J2EE sessions on from CF Administrator SERVER SETTINGS > Memory Variables - rrk
Are the clients that lose sessions ever working correctly or do they always drop sessions? Are they all using the same domain or do you have multiple domains hitting this app? - J.T.
What file is this? Is this your "Application.cfm" file or are you using <cfapplication...> in a regular file? - Mark A Kruger
See J.T.'s comments. CF can allow so strange stuff with cross-domain sessions, especially if you have multiple server instances on different sub-domains. We had this same issue when one CF server on the main domain was using site wide sessions and our server on the sub-domain had the same thing set. We had to switch ours to J2EE to fix the issue. So do you have other servers/domains also running CF? - Leeish

1 Answers

0
votes

Session variables expire so you need to check if they are available before you can use them. In your messages.cfm file you have to check if the user still have a valid session and if it doesn't redirect them to the login page. If they do have a valid session you can update the messages.