Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set expiry time... #50

Open
bostonareahuman opened this issue Feb 25, 2022 · 1 comment
Open

Unable to set expiry time... #50

bostonareahuman opened this issue Feb 25, 2022 · 1 comment

Comments

@bostonareahuman
Copy link

The expires/max age for the cookie is

2022-02-25T03:18:25.063Z

$setCookie = SetCookie::create('lu2')
			->withValue('aaaa')
			->withExpires(new \DateTime('+5 years'))
			->withMaxAge(500)
			->rememberForever()
			->withPath('/')
			->withDomain('192.168.1.13')
			->withSecure(false)
			->withHttpOnly(true)
			->withSameSite(SameSite::lax());
		echo $setCookie;
		$response = FigResponseCookies::set($response, $setCookie);
		return $response->withStatus(201)
			->withHeader("Content-Type", "application/json")
			->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));

@simensen
Copy link
Member

When I run the same code, I get expires/max age:

lu2=aaaa; Domain=192.168.1.13; Path=/; Expires=Fri, 26 Feb 2027 20:55:46 GMT; Max-Age=500; HttpOnly; SameSite=Lax

What is the complete output you receive when you run that? Also, which version of PHP are you running? and what do you get if you run this?

echo (new \DateTime('+5 years'))->format('c')."\n";

For me, I see this:

2027-02-26T20:57:29+00:00

My PHP version:

PHP 8.1.3 (cli) (built: Feb 18 2022 09:32:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.3, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.3, Copyright (c), by Zend Technologies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants