TIPS - Auto-login a Joomla! user using a PHP oneliner
- Written by: M. Alexandre ELISÉ

Here is the code:
/**
* @var bool $result_login true on successful login, false otherwise
*/
$result_login = Factory::getApplication()->login(
[
'username' => 'example',
'password' => 'mysupersecretpassword'
],
[
'remember' => true,
'silent' => true
]
);
Interesting options:
remember: Enables remember me when auto-logged in
silent: Returns a boolean (in this case false rather than an exception if an authentication error occurs).
See you soon for new tips and tricks...