ZF2 - How to check if session remember me is still valid?

Say a ZF2 authentication storage retrieves the session manager in order to set a TTL:

class MyAuthStorage extends Storage\Session
{
    public function setRememberMe($rememberMe = 0, $time = 1209600)
    {
        if ($rememberMe == 1) {
            $this->session->getManager()->rememberMe($time);
        }
    }

...

}

How can one check whether the remember me TTL has expired? The apidoc is unclear, should I use isValid()?

Upvotes: 2

Views: 686

Answers (1)

Jan.J
Jan.J

Reputation: 3080

I can't get you specific answer to this cause there is no api for it (or I didn't found it). I found that remember me it is enabled by setting some positive number of seconds to session cookie lifetime. So using this method of session config instance you can probably check if remember me is valid.

You can also take a look at tests that check remember me functionality. https://github.com/zendframework/zend-session/blob/705d440e71b33c5ec2cf39496e7cba72e76eccb9/test/SessionManagerTest.php#L422

Upvotes: 1

Related Questions