As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
CometChat Update single-sign-on functionalityScroll 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 requirementsThen 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;}
<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>