88
99class Cookies implements CookiesInterface
1010{
11- private $ name ;
12- private $ value ;
13- private $ expires ;
11+ // private $name;
12+ // private $value;
13+ // private $expires;
1414 private $ path ;
1515 private $ domain ;
1616 private $ secure ;
17- private $ httponly ;
17+ private $ httpOnly ;
1818 private $ samesite ;
1919
2020 /**
21- * [__construct description]
22- * setcookie(
23- string $name,
24- string $value = "",
25- int $expires_or_options = 0,
26- string $path = "",
27- string $domain = "",
28- bool $secure = false,
29- bool $httponly = false
30- ): bool
31- * @param [type] $uri [description]
21+ * Set Cookie
22+ * @param string $path
23+ * @param string $domain
24+ * @param bool|boolean $secure
25+ * @param bool|boolean $httpOnly
3226 */
3327 public function __construct (
3428 string $ path = "/ " ,
3529 string $ domain = "" ,
3630 bool $ secure = true ,
37- bool $ httponly = true
31+ bool $ httpOnly = true
3832 ) {
3933 $ this ->path = $ path ;
4034 $ this ->domain = $ domain ;
4135 $ this ->secure = $ secure ;
42- $ this ->httponly = $ httponly ;
36+ $ this ->httpOnly = $ httpOnly ;
4337 }
4438
4539 /**
@@ -54,7 +48,7 @@ public function setPath(string $path)
5448
5549 /**
5650 * Set cookie allowed domain
57- * @param string $path URI Path
51+ * @param string $domain URI Path
5852 */
5953 public function setDomain (string $ domain )
6054 {
@@ -64,7 +58,7 @@ public function setDomain(string $domain)
6458
6559 /**
6660 * Set cookie secure flag (HTTPS only: true)
67- * @param string $path URI Path
61+ * @param string $secure URI Path
6862 */
6963 public function setSecure (bool $ secure )
7064 {
@@ -75,19 +69,18 @@ public function setSecure(bool $secure)
7569 /**
7670 * Set cookie http only flag. Cookie won't be accessible by scripting languages, such as JavaScript if true.
7771 * Can effectively help to reduce identity theft through XSS attacks, Not supported in all browsers tho
78- * @param string $path URI Path
72+ * @param bool $httpOnly enable http only flag
7973 */
80- public function setHttpOnly (bool $ httponly )
74+ public function sethttpOnly (bool $ httpOnly )
8175 {
82- $ this ->httponly = $ httponly ;
76+ $ this ->httpOnly = $ httpOnly ;
8377 return $ this ;
8478 }
8579
8680
8781 /**
88- * Set same site
89- * (Requires PHP version >= 7.3.0)
90- * @param string $sameSite [description]
82+ * Set same site (Requires PHP version >= 7.3.0)
83+ * @param string $samesite
9184 */
9285 public function setSameSite (string $ samesite )
9386 {
@@ -110,7 +103,7 @@ public function set(string $name, string $value, int $expires, bool $force = fal
110103 if (version_compare (PHP_VERSION , '7.3.0 ' ) >= 0 ) {
111104 setcookie ($ name , $ value , $ this ->cookieOpt ($ expires ));
112105 } else {
113- setcookie ($ name , $ value , $ expires , $ this ->path , $ this ->domain , $ this ->secure , $ this ->httponly );
106+ setcookie ($ name , $ value , $ expires , $ this ->path , $ this ->domain , $ this ->secure , $ this ->httpOnly );
114107 }
115108 if ($ force ) {
116109 $ _COOKIE [$ name ] = $ value ;
@@ -158,7 +151,7 @@ public function delete(string $name): void
158151 */
159152 public function isSecure (): bool
160153 {
161- return (bool )($ this ->samesite === "Strict " && $ this ->secure && $ this ->httponly );
154+ return (bool )($ this ->samesite === "Strict " && $ this ->secure && $ this ->httpOnly );
162155 }
163156
164157 /**
@@ -173,7 +166,7 @@ private function cookieOpt(int $expires): array
173166 'path ' => $ this ->path ,
174167 'domain ' => $ this ->domain ,
175168 'secure ' => $ this ->secure ,
176- 'httponly ' => $ this ->httponly ,
169+ 'httponly ' => $ this ->httpOnly ,
177170 'samesite ' => $ this ->samesite
178171 ];
179172 }
0 commit comments