Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2627

Joomla! 5.x Coding • Re: Get user from site application in J5

$
0
0
Thank for reply. I have added bot for some reason it didn't work. but now it seems ok but I get null even if the user is logged in.

Code:

<?phpdefine('_JEXEC', 1);defined('_JEXEC') or die;define('JPATH_BASE','../');require_once JPATH_BASE . '/includes/defines.php';require_once JPATH_BASE . '/includes/framework.php';use Joomla\CMS\Factory;use Joomla\CMS\Log\Log;use Joomla\CMS\Helper\ModuleHelper;use Joomla\Session\SessionInterface;use Joomla\CMS\Application\SiteApplication;$container = Factory::getContainer();$container->alias(SessionInterface::class, 'session.web.site');$app = $container->get(SiteApplication::class);
I have tried to use $user = $app->getIdentity();
and if (Factory::$application === null) {
Factory::$application = $app;
}
Both shows in var_dump($user); null so I have tried var_dump on $app and it actually doesn't contain any logged user data.

Statistics: Posted by Poutnik81 — Mon Jan 08, 2024 1:25 pm



Viewing all articles
Browse latest Browse all 2627

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>