1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Logged in User's ID in Memcache

Discussion in 'General XenForo Discussion and Feedback' started by Harshita, Dec 4, 2015.

Thread Status:
Not open for further replies.
  1. Harshita

    Harshita New Member


    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);
    $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.
  2. Mike

    Mike XenForo Developer Staff Member

    Please associate your forum user with your customer account. You will then be able to post in the development section.
    Amaury likes this.
Thread Status:
Not open for further replies.

Share This Page