Hi,

I have a login form which also has a simple checkbox for the user to
determine if he wants a short living or long living cookie for the login.

For Authentication I use the Zend\Authentication\AuthenticationService
within my user service which is kept in $this->authentication. Now here
is my solution so far. The $user array holds the data from the login form.

-----------------------------------------------------------------------
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Storage\Session;
use Zend\Session\Container;

[...]

// get authentication
$authentication = $this->authentication;
$authentication->getAdapter()->setIdentity($user['email']);
$authentication->getAdapter()->setCredential($user['password']);

// check expire
if ($user['expire'] == 'yes') {
    $authNamespace = new Container(Session::NAMESPACE_DEFAULT);
    $authNamespace->getManager()->rememberMe(2000);
} else {
    $authNamespace = new Container(Session::NAMESPACE_DEFAULT);
    $authNamespace->getManager()->rememberMe(10);
}

// authenticate
$result = $authentication->authenticate();
-----------------------------------------------------------------------

This looks a little awkward and I wonder if there is a more elegant
solution without creating new Zend\Session\Container objects. With
$authentication->getStorage() I can get the storage but the session
container in the storage is not accessible.

One idea could be to create my own Storage class which allows the access
of the session container. But I don't know if that would be a good solution.

Please advise!

Thanks and best regards,

Ralf

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to