Advertisement:

Author Topic: cookie and cometchat  (Read 495 times)

gnik

  • Newbie
  • *
  • Posts: 3
cookie and cometchat
« on: February 07, 2018, 01:14:37 am »
Hi,
Please help if you can.

I am using the Gum Theme
and I have installed CometChat
I have set Cometchat to login user with the osclass login
However its not working
Comet chat have provided this information to me:

Kindly follow the following steps to create a cookie or unset a cookie, to configure chat with your application. Thus you need to create a cc_data cookie, which stores logged in user's id. When user is logged in, in your application.

 
When you login, use the following format to set the cookie

setcookie('cc_data', $userid, time() + (86400 * 30), "/");

 

And when the user is logged out from your application, you need to unset the cc_data cookie in the following manner.


When you logout use the following format to un set the cookie

setcookie('cc_data', '', -time() + (86400 * 30), "/");

 

Also in installation.php file which is in "CometChat" folder change below things

find "getUserID" and just before "$userid = intval($userid);"

if (!empty($_COOKIE['cc_data'])) {
     $userid = $_COOKIE['cc_data'];
}
 
Note: This article would help you when you are not able to set user information in a session. For example, you are using Codeigniter or using a cloud solution. When user login is needed, and you are unable login user, we ask you to create a cookie named "cc_data" as described above.


However, I do not know where to insert/replace the code in osclass?

Any help would be appreciated

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: cookie and cometchat
« Reply #1 on: February 07, 2018, 04:53:14 pm »
Hi,

For cookie management on Osclass side:

Add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.

Code: [Select]
<?php
function cust_cometchat_login($user) {
    
setcookie('cc_data'$user['pk_i_id'], time() + (86400 30), "/");
}

osc_add_hook('after_login''cust_cometchat_login');

function 
cust_cometchat_logout() {
    
setcookie('cc_data''', -time() + (86400 30), "/");
}

osc_add_hook('logout''cust_cometchat_logout');
?>


Regards

gnik

  • Newbie
  • *
  • Posts: 3
Re: cookie and cometchat (SOLVED)
« Reply #2 on: February 08, 2018, 11:30:09 am »
Thank you very much Teseo
It works
I really appreciate it

Nik

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: cookie and cometchat
« Reply #3 on: February 08, 2018, 01:09:01 pm »
You're welcome. :)

Regards