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

Add DateTimeInterface to setCookie $expire param #237

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Sets the expiration of the HTTP document using the `Cache-Control` and `Expires`
$httpResponse->setExpiration('1 hour');
```

setCookie(string $name, string $value, $time, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null, string $sameSite = null)
setCookie(string $name, string $value, string|int|\DateTimeInterface|null $expire, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null, string $sameSite = null)
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Sends a cookie. The default values ​​of the parameters are:
- `$path` with scope to all directories (`'/'`)
Expand All @@ -316,7 +316,7 @@ Sends a cookie. The default values ​​of the parameters are:
- `$httpOnly` is true, so the cookie is inaccessible to JavaScript
- `$sameSite` is null, so the flag is not specified

The time can be specified as a string or the number of seconds.
The `$expire` parameter can be specified as a string, an object implementing `DateTimeInterface`, or the number of seconds.

```php
$httpResponse->setCookie('lang', 'en', '100 days');
Expand Down
2 changes: 1 addition & 1 deletion src/Http/IResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ function getHeaders(): array;
function setCookie(
string $name,
string $value,
?int $expire,
string|int|\DateTimeInterface|null $expire,
?string $path = null,
?string $domain = null,
?bool $secure = null,
Expand Down
Loading