Class

Symfony\Component\BrowserKit\Cookie

class Cookie

Cookie represents an HTTP cookie.

Methods

__construct(string $name, string $value, string $expires = null, string $path = null, string $domain = '', bool $secure = false, bool $httponly = true, bool $encodedValue = false)

Sets a cookie.

string __toString()

Returns the HTTP representation of the Cookie.

static Cookie fromString(string $cookie, string $url = null)

Creates a Cookie instance from a Set-Cookie header value.

string getName()

Gets the name of the cookie.

string getValue()

Gets the value of the cookie.

string getRawValue()

Gets the raw value of the cookie.

string getExpiresTime()

Gets the expires time of the cookie.

string getPath()

Gets the path of the cookie.

string getDomain()

Gets the domain of the cookie.

bool isSecure()

Returns the secure flag of the cookie.

bool isHttpOnly()

Returns the httponly flag of the cookie.

bool isExpired()

Returns true if the cookie has expired.

Details

at line 62
public __construct(string $name, string $value, string $expires = null, string $path = null, string $domain = '', bool $secure = false, bool $httponly = true, bool $encodedValue = false)

Sets a cookie.

Parameters

string $name The cookie name
string $value The value of the cookie
string $expires The time the cookie expires
string $path The path on the server in which the cookie will be available on
string $domain The domain that the cookie is available
bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
bool $httponly The cookie httponly flag
bool $encodedValue Whether the value is encoded or not

at line 88
public string __toString()

Returns the HTTP representation of the Cookie.

Return Value

string The HTTP representation of the Cookie

Exceptions

UnexpectedValueException

at line 133
static public Cookie fromString(string $cookie, string $url = null)

Creates a Cookie instance from a Set-Cookie header value.

Parameters

string $cookie A Set-Cookie header value
string $url The base URL

Return Value

Cookie A Cookie instance

Exceptions

InvalidArgumentException

at line 232
public string getName()

Gets the name of the cookie.

Return Value

string The cookie name

at line 244
public string getValue()

Gets the value of the cookie.

Return Value

string The cookie value

at line 256
public string getRawValue()

Gets the raw value of the cookie.

Return Value

string The cookie value

at line 268
public string getExpiresTime()

Gets the expires time of the cookie.

Return Value

string The cookie expires time

at line 280
public string getPath()

Gets the path of the cookie.

Return Value

string The cookie path

at line 292
public string getDomain()

Gets the domain of the cookie.

Return Value

string The cookie domain

at line 304
public bool isSecure()

Returns the secure flag of the cookie.

Return Value

bool The cookie secure flag

at line 316
public bool isHttpOnly()

Returns the httponly flag of the cookie.

Return Value

bool The cookie httponly flag

at line 328
public bool isExpired()

Returns true if the cookie has expired.

Return Value

bool true if the cookie has expired, false otherwise