Harshita
New member
Hello,
I have enabled Memcached as a backend for caching system. I am developing a plugin in which I need to get the ID of the logged in user. Can someone help me out to find as to how can I retrieve the ID when memcached is enabled.
P.S the following code snippet that I had used which did not work:
if($userid == 0){
$fileDir = dirname(dirname(__FILE__));
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Session::startPublicSession();
$visitor = XenForo_Visitor::getInstance()->toArray();
$userid = $visitor['user_id'];
}
This code helped me get the userid, but throws a Fatal error while re-installing my plugin.
Please help.
I have enabled Memcached as a backend for caching system. I am developing a plugin in which I need to get the ID of the logged in user. Can someone help me out to find as to how can I retrieve the ID when memcached is enabled.
P.S the following code snippet that I had used which did not work:
if($userid == 0){
$fileDir = dirname(dirname(__FILE__));
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Session::startPublicSession();
$visitor = XenForo_Visitor::getInstance()->toArray();
$userid = $visitor['user_id'];
}
This code helped me get the userid, but throws a Fatal error while re-installing my plugin.
Please help.