Support the ongoing development of Laravel.io →
posted 10 years ago
Session
Last updated 2 years ago.
0

I recently faced the same issue when trying to integrate CometChat into project of mine. After a bit trial and error, the following code is what I came up with:

// set up autoloader
$base_path = dirname(dirname(dirname(__FILE__)));
include_once($base_path.'\vendor\autoload.php');

$laravel_db_config_file = $base_path . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'database.php';
if (!file_exists($laravel_db_config_file))
{
    echo "Please make sure you have the Cometchat folder in the public folder of your laravel site";
}

include_once($base_path.'\bootstrap\autoload.php');
$app = include_once($base_path.'\bootstrap\start.php');
$config = include_once($laravel_db_config_file);

$dbl = $config['connections']['mysql'];

I am assuming you have an integration file that holds the get_user_id method as well as any configuration. At the point of login on my app, I added a new session key called userid using Session::set('userid', Auth::user()->id). To access this in ArrowChat, simple use:

Session::get('userid')

Your final code should then look like:

if (Session::get('userid')) 
     {
$userid = Session::get('userid');
      }

     return $userid;

Hope this helps a bit...

Emmanuel

Last updated 2 years ago.
0

thanks for your solution grafikkaos , I am successful to connected to get user_id but I am not unable to chat with others user even with with no friends system (all online) . Any solution ? I just saw the bar only

Last updated 2 years ago.
0

Hi Andy,

Can you forward me your email address if possible?

Thanks

Last updated 2 years ago.
0

@grafikkaos one question where did you placed the // set up autoloader code in the cometchat files? in the integration.php?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

andywongcg andywongcg Joined 27 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.