WpOrg\Requests
Cookie::format_for_set_cookie
Format a cookie for a Set-Cookie header
This is used when sending cookies to clients. This isn't really applicable to client-side usage, but might be handy for debugging.
Method of the class: Cookie{}
No Hooks.
Returns
String. Cookie formatted for Set-Cookie header
Usage
$Cookie = new Cookie(); $Cookie->format_for_set_cookie();
Cookie::format_for_set_cookie() Cookie::format for set cookie code WP 7.0
public function format_for_set_cookie() {
$header_value = $this->format_for_header();
if (!empty($this->attributes)) {
$parts = [];
foreach ($this->attributes as $key => $value) {
// Ignore non-associative attributes
if (is_numeric($key)) {
$parts[] = $value;
} else {
$parts[] = sprintf('%s=%s', $key, $value);
}
}
$header_value .= '; ' . implode('; ', $parts);
}
return $header_value;
}