Skip to content

Commit df2492c

Browse files
committed
Format cookie value must be string.
1 parent 49e93f7 commit df2492c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Cookie/Cookie.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function __construct(
8181
}
8282

8383
$this->name = $name;
84-
$this->value = $value;
84+
$this->value = (string) $value;
8585
$this->domain = $domain;
8686
$this->expire = 0 < $expire ? (int) $expire : 0;
8787
$this->path = empty($path) ? '/' : $path;
@@ -208,7 +208,7 @@ public function getName()
208208
/**
209209
* Gets the value of the cookie.
210210
*
211-
* @return null|string
211+
* @return string
212212
*/
213213
public function getValue()
214214
{

src/Server/Response.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@ public function send()
134134
foreach ($paths ?? [] as $path => $item) {
135135
foreach ($item ?? [] as $name => $cookie) {
136136
if ($cookie instanceof Cookie) {
137-
$this->swooleResponse->cookie($cookie->getName(), $cookie->getValue() ?: 1, $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
137+
$this->swooleResponse->cookie(
138+
$cookie->getName(),
139+
$cookie->getValue(),
140+
$cookie->getExpiresTime(),
141+
$cookie->getPath(),
142+
$cookie->getDomain(),
143+
$cookie->isSecure(),
144+
$cookie->isHttpOnly()
145+
);
138146
}
139147
}
140148
}

0 commit comments

Comments
 (0)