Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
achef Posted March 22, 2019 Posted March 22, 2019 Is it possible to check if a user is currently logged into the community with an external php page through $_SESSION or something like that?
Norbee. Posted March 23, 2019 Posted March 23, 2019 Yes. If you include the init.php from the forum after that like this. <?php /* Require the init.php file from the Community Suite root directory */ require 'init.php'; /* Initiate the session to verify who this user is */ \IPS\Session\Front::i(); echo \IPS\Member::loggedIn()->name; ?> After you include the init.php you can use most of the forum function 😄
Ryan Ashbrook Posted March 23, 2019 Posted March 23, 2019 Actually, I would recommend using \IPS\Dispatcher\External::i(); rather than \IPS\Session\Front::i();
Tom S. Posted March 23, 2019 Posted March 23, 2019 4 hours ago, Ryan Ashbrook said: Actually, I would recommend using \IPS\Dispatcher\External::i(); rather than \IPS\Session\Front::i(); Just for my info, could you explain the difference between the two?
bfarber Posted March 25, 2019 Posted March 25, 2019 On 3/23/2019 at 5:44 PM, Tom S. said: Just for my info, could you explain the difference between the two? The external dispatcher sets up a few things under the premise that you're executing code but not within the Suite itself (using the framework, but in a standalone script). This is safer than simply loading the session handler, which may rely on other classes). Consider it a best practice tip.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.