How to implement my own login?

Hi, Guys

I want to implement auto login for my site,
This’s my script but not work.

public function onPluginsInitialized()
    {
        // if my login logic success, try to persist authenticated user to session
        if ($this->isAdminPath() && $this->autoLogin()) {
            $user = User::load('adminuser');
            $user->authenticated = true;

            $this->grav['session']->user = $user;

            unset($this->grav['user']);
            $this->grav['user'] = $user;

            /** @var Uri $uri */
            $uri = $this->grav['uri']; 

            // redirect to default admin page
            header('Location: ' . $uri->rootUrl() . $this->config->get('plugins.admin.route'));
            die();
        }
}

How i can done to save login user?

Thanks.