Skip to content

Commit 85b71ee

Browse files
spazedg
authored andcommitted
IResponse: added DateTimeInterface to setCookie $expire param (#237)
1 parent 6867c5d commit 85b71ee

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Sets the expiration of the HTTP document using the `Cache-Control` and `Expires`
307307
$httpResponse->setExpiration('1 hour');
308308
```
309309

310-
setCookie(string $name, string $value, $time, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null, string $sameSite = null)
310+
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)
311311
--------------------------------------------------------------------------------------------------------------------------------------------------------------
312312
Sends a cookie. The default values ​​of the parameters are:
313313
- `$path` with scope to all directories (`'/'`)
@@ -316,7 +316,7 @@ Sends a cookie. The default values ​​of the parameters are:
316316
- `$httpOnly` is true, so the cookie is inaccessible to JavaScript
317317
- `$sameSite` is null, so the flag is not specified
318318

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

321321
```php
322322
$httpResponse->setCookie('lang', 'en', '100 days');

src/Http/IResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ function getHeaders(): array;
397397
function setCookie(
398398
string $name,
399399
string $value,
400-
?int $expire,
400+
string|int|\DateTimeInterface|null $expire,
401401
?string $path = null,
402402
?string $domain = null,
403403
?bool $secure = null,

0 commit comments

Comments
 (0)