How to Check Cookie ? Help

wmnitin

Member
Hello, I am creating my own php application. Actually i want to get userid of logged in user. As far as i know first i have to get cookie.

So, here is code that i have placed in /library/mycode/example/index.php

Code:
class Mycode_Example_index
{
public static function getHtml()
{  

  $nit= (isset($_COOKIE["xf_user"]) ? $_COOKIE["xf_user"] : '');

  if ($nit) {
   echo "display information for users who are logged on";
  }

  if (!$nit) {
   echo "display information for users who are not logged on";
  }
}
}

Now i am using it with callback <xen:callback class="Mycode_Example_index" method="getHtml"></xen:callback>

But it is showing not logged on...even i am logged in !
 
Actually I have resolved it by using another way ! ;) But still experts comments needed abt whats wrong in this code :)
 
I added some extra lines

XenForo_Session::startPublicSession();

$visitor = XenForo_Visitor::getInstance()->toArray();

then got userid from $visitor :cool: Hope it will also help others (y)
 
Back
Top Bottom