Skip to content

Commit

Permalink
IResponse: added DateTimeInterface to setCookie $expire param (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
spaze authored and dg committed Nov 4, 2024
1 parent 6867c5d commit 85b71ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit 85b71ee

Please sign in to comment.