07-14-2011 01:33 AM
CometChat 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 a cookie then 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;
}
07-25-2011 02:23 PM
<script>
var userid='USERID'; //this is where I cannot figure out how to populate USERID with the proper information from alf_authority for the logged in user
document.cookie="cc_data="+userid;
</script>
07-26-2011 04:56 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.