Symfony\Component\HttpFoundation\Cookie::getMaxAge PHP Method

getMaxAge() public method

Gets the max-age attribute.
public getMaxAge ( ) : integer
return integer
    public function getMaxAge()
    {
        return 0 !== $this->expire ? $this->expire - time() : 0;
    }

Usage Example

Example #1
0
    public function testGetMaxAge()
    {
        $cookie = new Cookie('foo', 'bar');
        $this->assertEquals(0, $cookie->getMaxAge());

        $cookie = new Cookie('foo', 'bar', $expire = time() + 100);
        $this->assertEquals($expire - time(), $cookie->getMaxAge());

        $cookie = new Cookie('foo', 'bar', $expire = time() - 100);
        $this->assertEquals($expire - time(), $cookie->getMaxAge());
    }