Jump to content

Loading member


Niko Belger

Recommended Posts

Posted

 

Hello,

I'm trying to fetch the current logged in member with

  $member = \IPS\Member::loggedIn();

However, I always get the following exception (regardless if logged in or not)

'LOCATION_UNKNOWN' in /forum/system/Session/Session.php:60 Stack trace: #0 /forum/system/Member/Member.php(145): IPS\_Session::i() #1 /forum/hwid/API/API.php(14): IPS\_Member::loggedIn() #2 {main}

 

any suggestions?

 

Posted

You need to provide a bit more context.  

Based on that error, it appears this is a script outside the IPS framework...If that's the case, it doesn't know if you're on the front end or AdminCP.  

/* Require the init.php file from the Community Suite root directory */
require '/path/to/suite/init.php';

/* Initiate the session to verify who this user is */
\IPS\Session\Front::i();

$member = \IPS\Member::loggedIn();
Posted

I use the same way in another script, however there I do not get anny error. What exactly do you mean by running outisde the framework

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require_once('/srv/public_html/forum/init.php');

//Check permissions
\IPS\Session\Front::i();

try {
  $member = \IPS\Member::loggedIn();
} catch(  \RuntimeException $ex )
{
		echo $ex;
}
print_r($member);

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...