HTTP cookie.
More...
|
| | __construct ($name, $value= '') |
| | Constructor. More...
|
| |
| | __toString () |
| | Converts cookie to string, which is suitable for HTTP request. More...
|
| |
| | getName () |
| | Returns cookie name. More...
|
| |
| | getValue () |
| | Returns cookie value. More...
|
| |
| | getPath () |
| | Returns cookie path. More...
|
| |
| | getDomain () |
| | Returns cookie domain. More...
|
| |
| | isExactDomain () |
| | Returns true, if cookie domain must match to server domain exactly. More...
|
| |
| | getExpires () |
| | Returns cookie expiry UNIX timestamp. More...
|
| |
| | isHttpOnly () |
| | Returns true, if cookie has HttpOnly attribute. More...
|
| |
| | isSecure () |
| | Returns true, if cookie can be sent only over HTTPS. More...
|
| |
| | setName ($name) |
| | Sets cookie name. More...
|
| |
| | setValue ($value) |
| | Sets cookie value. More...
|
| |
| | setPath ($path) |
| | Sets cookie path. More...
|
| |
| | setDomain ($domain, $exact=false) |
| | Sets cookie domain. More...
|
| |
| | setExpires ($expires) |
| | Sets cookie expiry time. More...
|
| |
| | setHttpOnly ($http_only=true) |
| | Sets if cookie has HTTP only attribute. More...
|
| |
| | setSecure ($secure=true) |
| | Sets if cookie can be sent only over HTTPS. More...
|
| |
| | isExpired ($current_time) |
| | Returns true, if cookie is expired. More...
|
| |
| | isAccepted ($domain, $path, $secure) |
| | Returns true, if cookie can be sent to specified domain, path and protocol. More...
|
| |
| | toResponseString () |
| | Returns cookie string that corresponds to Set-Cookie header format. More...
|
| |
HTTP cookie.
- Examples:
- http_cookies.php.
| __construct |
( |
|
$name, |
|
|
|
$value = '' |
|
) |
| |
Constructor.
- Parameters
-
| string | $name | Cookie name |
| mixed | $value | Cookie value (any scalar PHP type) |
Converts cookie to string, which is suitable for HTTP request.
See also HttpCookie::toResponseString.
- Return values
-
| string | Cookie string value |
Creates HttpCookie object from cookie header value string.
- Parameters
-
| string | $str | Value of Set-Cookie header |
| WebRequest | $request | Original WebRequest is needed to check/calculate domain and path of cookie. Can be null. If WebRequest is passed, then domain and path of cookie will be calculated if needed and checked properly. |
| ICookieTimeProvider | $cookie_time_provider | Cookie time provider, can be passed to provide the time, which can be used for "expires" value calculation. Can be null. |
- Return values
-
Returns cookie expiry UNIX timestamp.
- Return values
-
| string | Cookie expiry UNIX timestamp |
| isAccepted |
( |
|
$domain, |
|
|
|
$path, |
|
|
|
$secure |
|
) |
| |
Returns true, if cookie can be sent to specified domain, path and protocol.
- Parameters
-
| string | $domain | Host domain |
| string | $path | Request URI path portion |
| bool | $secure | If true, HTTPS protocol, otherwise HTTP |
- Return values
-
| string | True, if cookie can be sent to specified domain, path and protocol |
Returns true, if cookie domain must match to server domain exactly.
- Return values
-
| string | True, if cookie domain must match to server domain exactly |
| isExpired |
( |
|
$current_time | ) |
|
Returns true, if cookie is expired.
- Parameters
-
| mixed | $current_time | Can be null, which means session end. Can be int (current UNIX timestamp) |
- Return values
-
| string | True, if cookie is expired |
Returns true, if cookie has HttpOnly attribute.
- Return values
-
| string | True, if cookie has HttpOnly attribute |
Returns true, if cookie can be sent only over HTTPS.
- Return values
-
| string | True, if cookie can be sent only over HTTPS |
| static parseCookieDate |
( |
|
$cookie_date | ) |
|
|
static |
Parses cookie date string to UNIX timestamp.
- Parameters
-
| string | $cookie_date | Cookie date string |
- Return values
-
| int | UNIX timestamp or null on error |
| setDomain |
( |
|
$domain, |
|
|
|
$exact = false |
|
) |
| |
Sets cookie domain.
- Parameters
-
| string | $domain | Cookie domain |
| bool | $exact | If true, exact domain matching must be performed by isAccepted |
Sets cookie expiry time.
- Parameters
-
| int | $expires | Cookie expiry time (UNIX timestamp) |
| setHttpOnly |
( |
|
$http_only = true | ) |
|
Sets if cookie has HTTP only attribute.
- Parameters
-
| bool | $http_only | If true, cookie has HTTP only attribute |
Sets cookie name.
- Parameters
-
Sets cookie path.
- Parameters
-
| setSecure |
( |
|
$secure = true | ) |
|
Sets if cookie can be sent only over HTTPS.
- Parameters
-
| bool | $secure | If true, cookie can be sent only over HTTPS |
Sets cookie value.
- Parameters
-
| mixed | $value | Cookie value (any PHP scalar type) |
The documentation for this class was generated from the following file: