1

Topic: Cometchat integration , almost ready to present to you all.

Hi all !!
I have been trying to integrate Cometchat to sharetronix. Everything is perfect now. I just wish to ask a simple question , if anybody out here can explain it to me.
The stand alone integration asks login function for sharetronix. it says : (visit http://www.cometchat.com/knowledgebase/ … standalone for detail)

3. Update single-sign-on functionality

Scroll down to find the getUserID() function.

The getUserID() function is used to return the logged in user's ID. Depending on how you have programmed your site, you will have to find out the user's ID.

If you have written a simple PHP authentication, then during the authentication, you can specify a session variable like:

/* In your own login.php *//* After you authenticate the user */$_SESSION['userid'] = $users['id']; // Modify to suit requirements

Then your getUserID() function will look like:

function getUserID() {    $userid = 0; // Return 0 if user is not logged in        if (!empty($_SESSION['userid'])) {        $userid = $_SESSION['userid'];    }    return $userid;}

If you are using another language like ASP, ColdFusion, Python etc. then set a cookie immediately after login with the user's ID. You can read that using the following function:

function getUserID() {    $userid = 0; // Return 0 if user is not logged in        if (!empty($_COOKIE['userid'])) {        $userid = $_COOKIE['userid'];    }    return $userid;}

If you are using a more complex method of authentication like storing the session_hash in the database, then your getUserID() function will look something like:

function getUserID() {    $userid = 0; // Return 0 if user is not logged in        if (!empty($_COOKIE['sessionhash'])) {        $sql = ("select userid from ".TABLE_PREFIX."session             where sessionhash = '".mysql_real_escape_string($_COOKIE['sessionhash'])."'");        $query = mysql_query($sql);        $session = mysql_fetch_array($query);        $userid = $session['userid'];        }    return $userid;}

NOw if somebody can explain that ?

Thumbs up +1 Thumbs down

2

Re: Cometchat integration , almost ready to present to you all.

hello, can u share how did you integrate cometchat?

Thumbs up Thumbs down