Firefox PHP

Cometchat - how to get session?

Posted by networkinghomer 
Cometchat - how to get session?
May 14, 2015 05:36PM
Hi,

to get cometchat in touch with phorum, comtchat must know the name of the usersession (i think):

I quoted some instructions from http://www.cometchat.com/documentation/installing-cometchat/custom-coded-site/php-site/:

[quote="

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'];
}
$userid = intval($userid);
return $userid;
}

If you are using a cookie then configure the same using the following function:

function getUserID() {
$userid = 0; // Return 0 if user is not logged in

if (!empty($_COOKIE['userid'])) {
$userid = $_COOKIE['userid'];
}
$userid = intval($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'];
}
$userid = intval($userid);
return $userid;
}

"]

[/quote]

Can anybody tel me how to edit the code?

Cheers,
Homer
Re: Cometchat - how to get session?
June 07, 2015 12:21PM
The guys from cometchat.com sloved the problem. If anyone is interesstet in the files: Please write a PM :-)
Sorry, only registered users may post in this forum.

Click here to login