Requests_Cookie::format_for_set_cookie() WordPress Method

The Requests_Cookie::format_for_set_cookie() method is used to format a cookie for use in a Set-Cookie header.

Requests_Cookie::format_for_set_cookie() #

Format a cookie for a Set-Cookie header


Description

This is used when sending cookies to clients. This isn’t really applicable to client-side usage, but might be handy for debugging.


Top ↑

Return

(string) Cookie formatted for Set-Cookie header


Top ↑

Source

File: wp-includes/Requests/Cookie.php

	public function format_for_set_cookie() {
		$header_value = $this->format_for_header();
		if (!empty($this->attributes)) {
			$parts = array();
			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;
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.