Kohana 3.3 after login with auth shows user not logged in

128 Views Asked by At

I have a small app written in kohana 3.3. For login purposes I use auth module to log in as user.

Log in is simple and looks like that:

$auth = Auth::instance()->login($_POST['login']['username'], $_POST['login']['password']);
if(!$auth){
     // fails + redirect
}else{
     //success + redirect to user account
}

Auth config:

enter image description here

And user data is stored in db (password hashed):

enter image description here

Problem is that auth is log in me with no problem. There is always "success" when I pass correct login and password. But after that I redirect user to account and controller detects that user is not logged:

public function before() {
    parent::before();

    if (!Auth::instance()->logged_in()) {
            HTTP::redirect('/User/login');
    }
}

Even if I use redirect to homepage I am still not logged in. It looks like session data is lost. Strange is that it was working for a long time and suddenly a day ago it stopped.

Many thanks for any advices!

2

There are 2 best solutions below

0
Marek Kaliszuk On

For future generations... I have changed session_type from native to cookie and log in is working. Why? I don't have a good answear.

0
WinterSilence On
 Auth::login($username, $password, $remember = FALSE)

pass TRUE at $remember