@@ -70,15 +70,15 @@ Available methods in this library:
70
70
71
71
``` php
72
72
/**
73
- * Default options:
73
+ * Cookie options:
74
74
*
75
- * domain: '' - Domain for which the cookie is available.
76
- * expires: 0 - The time the cookie will expire.
77
- * httpOnly: false - If cookie will only be available through the HTTP protocol.
78
- * path: '/' - Path for which the cookie is available.
79
- * raw: false - If cookie will be sent as a raw string.
80
- * sameSite: null - Enforces the use of a Lax or Strict SameSite policy.
81
- * secure: false - If cookie will only be available through the HTTPS protocol.
75
+ * domain: Domain for which the cookie is available.
76
+ * expires: The time the cookie will expire.
77
+ * httpOnly: If cookie will only be available through the HTTP protocol.
78
+ * path: Path for which the cookie is available.
79
+ * raw: If cookie will be sent as a raw string.
80
+ * sameSite: Enforces the use of a Lax or Strict SameSite policy.
81
+ * secure: If cookie will only be available through the HTTPS protocol.
82
82
*
83
83
* These settings will be used to create and delete cookies.
84
84
*/
@@ -102,7 +102,11 @@ for supported date and time formats.
102
102
### Sets a cookie by name
103
103
104
104
``` php
105
- $cookie->set(string $name, mixed $value, null|int|string|DateTime $expires = null): void;
105
+ $cookie->set(
106
+ string $name,
107
+ mixed $value,
108
+ null|int|string|DateTime $expires = null
109
+ ): void
106
110
```
107
111
108
112
** @throws ** ` CookieException ` if headers already sent.
@@ -114,7 +118,10 @@ $cookie->set(string $name, mixed $value, null|int|string|DateTime $expires = nul
114
118
If cookies exist they are replaced, if they do not exist they are created.
115
119
116
120
``` php
117
- $cookie->replace(array $data, null|int|string|DateTime $expires = null): void
121
+ $cookie->replace(
122
+ array $data,
123
+ null|int|string|DateTime $expires = null
124
+ ): void
118
125
```
119
126
120
127
** @throws ** ` CookieException ` if headers already sent.
@@ -249,19 +256,28 @@ Cookie::set('foo', 'bar', new DateTime('now +1 hour'));
249
256
Without modifying the expiration time:
250
257
251
258
``` php
252
- $cookie->replace(['foo' => 'bar', 'bar' => 'foo']);
259
+ $cookie->replace([
260
+ 'foo' => 'bar',
261
+ 'bar' => 'foo'
262
+ ]);
253
263
```
254
264
255
265
Modifying the expiration time:
256
266
257
267
``` php
258
- $cookie->replace(['foo' => 'bar', 'bar' => 'foo'], time() + 3600);
268
+ $cookie->replace([
269
+ 'foo' => 'bar',
270
+ 'bar' => 'foo'
271
+ ], time() + 3600);
259
272
```
260
273
261
274
[ Using the facade] ( #using-the-facade ) :
262
275
263
276
``` php
264
- Cookie::replace(['foo' => 'bar', 'bar' => 'foo'], time() + 3600);
277
+ Cookie::replace([
278
+ 'foo' => 'bar',
279
+ 'bar' => 'foo'
280
+ ], time() + 3600);
265
281
```
266
282
267
283
### - Gets a cookie by name
@@ -384,16 +400,13 @@ it will be taken instead of the **expires** value set in the cookie options.
384
400
expires: 'now +1 minute'
385
401
);
386
402
387
- $cookie->set('foo', 'bar'); // This cookie will expire in 1 minute
403
+ $cookie->set('foo', 'bar'); // Expires in 1 minute
388
404
389
- $cookie->set('bar', 'foo', 'now +8 days'); // This cookie will expire in 8 days
405
+ $cookie->set('bar', 'foo', 'now +8 days'); // Expires in 8 days
390
406
391
- $cookie->replace(['foo' => 'bar']); // This cookies will expire in 1 minute
407
+ $cookie->replace(['foo' => 'bar']); // Expires in 1 minute
392
408
393
- $cookie->replace( // This cookies will expire in 1 hour
394
- ['foo' => 'bar'],
395
- time() + 3600
396
- );
409
+ $cookie->replace(['foo' => 'bar'], time() + 3600); // Expires in 1 hour
397
410
```
398
411
399
412
- If the **expires** parameter passed in the options is a date/time string,
@@ -404,8 +417,7 @@ it is formatted when using the `set` or `replace` method and not when setting th
404
417
expires: 'now +1 minute', // It will not be formatted as unix time yet
405
418
);
406
419
407
- $cookie->set('foo', 'bar'); // It is will formatted now
408
- // and will expire 1 minute after this cookie is created
420
+ $cookie->set('foo', 'bar'); // It is will formatted now and expires in 1 minute
409
421
```
410
422
411
423
## Tests
@@ -456,7 +468,7 @@ composer tests
456
468
- [ ] Improve tests
457
469
- [ ] Improve documentation
458
470
- [ ] Improve English translation in the README file
459
- - [ ] Refactor code for disabled code style rules. See [ phpmd.xml] ( phpmd.xml ) and [ phpcs.xml ] ( phpcs.xml )
471
+ - [ ] Refactor code for disabled code style rules (see phpmd.xml and phpcs.xml)
460
472
461
473
## Changelog
462
474
0 commit comments