Hi All,
I have a Page_Controller class that extends ContentController. I tried to get the current user id by calling Member::currentUserId(), but it always returns 0. I looked at the code and saw that it called Session::get('loggedInAs'), so I tried calling that from my controller, still empty. If I print_r($_SESSION) it's there. Have I missed some trick or something that disallows sessions from ContentControllers?
My code is:
public function LoginLink()
{
$id = Member::currentUserID();
if ($id)
{
if (Member::isInGroup(1))
{
$link = 'admin';
}
else if (Member::isInGroup(2))
{
$link = 'partner-login';
}
else
{
$link = 'home';
}
return sprintf('<a href="%s%s">My Account</a>', Director::baseURL(), $link);
}
return '';
}
and it's called from inside the template