|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @category Brownie/HttpClient |
|
4
|
|
|
* @author Brownie <[email protected]> |
|
5
|
|
|
* @license https://opensource.org/licenses/MIT |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Brownie\HttpClient\Cookie; |
|
9
|
|
|
|
|
10
|
|
|
use Brownie\Util\StorageArray; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* HTTP Cookie class. |
|
14
|
|
|
* |
|
15
|
|
|
* @method Cookie setName(string $name) Sets the name of the cookie. |
|
16
|
|
|
* @method string getName() Returns cookie name. |
|
17
|
|
|
* @method Cookie setValue(string $value) Sets the value of the cookie. |
|
18
|
|
|
* @method string getValue() Returns cookie value. |
|
19
|
|
|
* @method Cookie setExpires(string $expires) Sets time the cookie expires. |
|
20
|
|
|
* @method string getExpires() Returns time the cookie expires. |
|
21
|
|
|
* @method Cookie setPath(string $path) Sets path on the server in which the cookie will be available on. |
|
22
|
|
|
* @method string getPath() Returns path on the server in which the cookie will be available on. |
|
23
|
|
|
* @method Cookie setDomain(string $domain) Sets [sub]domain that the cookie is available to. |
|
24
|
|
|
* @method string getDomain() Returns [sub]domain that the cookie is available to. |
|
25
|
|
|
* @method Cookie setSecure(bool $secure) Indicates that the cookie should only be transmitted over |
|
26
|
|
|
* a secure HTTPS connection from the client. |
|
27
|
|
|
* @method bool getSecure() Returns the flag for sending cookies through a |
|
28
|
|
|
* secure HTTPS connection. |
|
29
|
|
|
* @method Cookie setHttponly(bool $httpOnly) When TRUE the cookie will be made accessible only |
|
30
|
|
|
* through the HTTP protocol. |
|
31
|
|
|
* @method bool getHttponly() Returns the cookie availability flag via the HTTP protocol. |
|
32
|
|
|
*/ |
|
33
|
|
|
class Cookie extends StorageArray |
|
34
|
|
|
{ |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* List of supported fields. |
|
38
|
|
|
* |
|
39
|
|
|
* @var array |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $fields = array( |
|
42
|
|
|
'name' => null, // The name of the cookie. |
|
43
|
|
|
'value' => null, // The value of the cookie. |
|
44
|
|
|
'expires' => '', // The time the cookie expires. |
|
45
|
|
|
'path' => '', // The path on the server in which the cookie will be available on. |
|
46
|
|
|
'domain' => '', // The (sub)domain that the cookie is available to. |
|
47
|
|
|
'secure' => false, // Indicates that the cookie should only be transmitted over |
|
48
|
|
|
// a secure HTTPS connection from the client. |
|
49
|
|
|
'httponly' => false, // When TRUE the cookie will be made accessible only through the HTTP protocol. |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Get the value as a string. |
|
54
|
|
|
* |
|
55
|
|
|
* @return null|string |
|
56
|
|
|
*/ |
|
57
|
2 |
|
public function toString() |
|
58
|
|
|
{ |
|
59
|
2 |
|
return $this->getName() . '=' . $this->getValue(); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|