1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Stdlib\Cookie;
/**
* Class PublicCookieMetadata
*
* @api
* @since 100.0.2
*/
class PublicCookieMetadata extends CookieMetadata
{
/**
* Set the number of seconds until the cookie expires
*
* The cookie duration can be translated into an expiration date at the time the cookie is sent.
*
* @param int $duration Time in seconds.
* @return $this
*/
public function setDuration($duration)
{
return $this->set(self::KEY_DURATION, $duration);
}
/**
* Set the cookie duration to one year
*
* @return $this
*/
public function setDurationOneYear()
{
return $this->setDuration(3600 * 24 * 365);
}
/**
* Get the number of seconds until the cookie expires
*
* The cookie duration can be translated into an expiration date at the time the cookie is sent.
*
* @return int|null Time in seconds.
*/
public function getDuration()
{
return $this->get(self::KEY_DURATION);
}
/**
* Set HTTPOnly flag
*
* @param bool $httpOnly
* @return $this
*/
public function setHttpOnly($httpOnly)
{
return $this->set(self::KEY_HTTP_ONLY, $httpOnly);
}
/**
* Set whether the cookie is only available under HTTPS
*
* @param bool $secure
* @return $this
*/
public function setSecure($secure)
{
return $this->set(self::KEY_SECURE, $secure);
}
}