Search code examples
sessionlaravelsession-cookiesremember-mecartalyst-sentry

Laravel 4.2: Sentry 2 Remember me function not working


I have tried to log the user in without remembering him (Sentry::authenticate($input, false);) and I get a cookie created, so I don't get disconnected when exiting my browser. Please find my code below

Controller

public function store()
{
    $this->loginForm->validate($input = Input::only('email', 'password'));

    try
    {
        if( Input::get('remember') ) {
            Sentry::authenticateAndRemember($input);
        } else {    
            Sentry::authenticate($input, false);
        }

    }

    catch (\Cartalyst\Sentry\Users\UserNotFoundException $e)
    {
        return Redirect::back()->withInput()->withErrorMessage('Invalid credentials provided');
    }
    catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e)
    {
        return Redirect::back()->withInput()->withErrorMessage('User Not Activated.');
    }
}

View

 <div class="checkbox">
    <!-- Remember me field -->
        <div class="form-group">
            {{ Form::label('remember_label', 'Remember Me? ')}}
            <input type="checkbox" name="remember">
        </div>
</div>

I have tried this but the result is same.

In php.ini I have set session.gc_maxlifetime = 2592000

Does anyone have any clue ?

Thanks for the suggestions.


Solution

  • At last I found the error I made, I am writing it below, so that it can be useful to someone else.

    Please edit app->config->session.php

    Session lifetime

    'lifetime' => 120,
    
    'expire_on_close' => true,