How to log a user in via script

SS42

in SS3, you can do this
Security::setCurrentUser($member);

but it seems not working any more?

it actually works. forget to force the page to reload.

Just FYI, there is also a Member::actAs($member, $callback) which might be useful, depending on what you’re trying to do.

https://docs.silverstripe.org/en/4/developer_guides/security/member/#acting-as-another-user

Take a look here: Log in a member - Silverstripe 4

@Tim great!