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

How to Check Cookie ? Help

#1
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 !
 
#4
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)