Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

How to implement my own login?

Started by Muut Archive 10 years ago · 0 replies · 356 views
10 years ago

Hi, Guys

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

PHP
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.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1279 9 years ago
Archive · by Muut Archive, 9 years ago
2 886 9 years ago
Archive · by Muut Archive, 9 years ago
2 4015 9 years ago
Archive · by Muut Archive, 9 years ago
1 2891 9 years ago
Archive · by Muut Archive, 9 years ago
3 1075 9 years ago