NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class Cookie

Set-Cookie object

  Guzzle\Plugin\Cookie\Cookie implements Guzzle\Common\ToArrayInterface

Namespace: Guzzle\Plugin\Cookie
Located at Guzzle/Plugin/Cookie/Cookie.php

## Methods summary

- `protected static` `getInvalidCharacters ( )`

  Gets an array of invalid cookie characters

- `public` `__construct ( array $data = array() )`
- `public` `toArray ( )`

  Get the cookie as an array

- `public` `getName ( )`

  Get the cookie name

- `public` `setName ( string $name )`

  Set the cookie name

- `public` `getValue ( )`

  Get the cookie value

- `public` `setValue ( string $value )`

  Set the cookie value

- `public` `getDomain ( )`

  Get the domain

- `public` `setDomain ( string $domain )`

  Set the domain of the cookie

- `public` `getPath ( )`

  Get the path

- `public` `setPath ( string $path )`

  Set the path of the cookie

- `public` `getMaxAge ( )`

  Maximum lifetime of the cookie in seconds

- `public` `setMaxAge ( int $maxAge )`

  Set the max-age of the cookie

- `public` `getExpires ( )`

  The UNIX timestamp when the cookie expires

- `public` `setExpires ( int $timestamp )`

  Set the unix timestamp for which the cookie will expire

- `public` `getVersion ( )`

  Version of the cookie specification. RFC 2965 is 1

- `public` `setVersion ( string|int $version )`

  Set the cookie version

- `public` `getSecure ( )`

  Get whether or not this is a secure cookie

- `public` `setSecure ( bool $secure )`

  Set whether or not the cookie is secure

- `public` `getDiscard ( )`

  Get whether or not this is a session cookie

- `public` `setDiscard ( bool $discard )`

  Set whether or not this is a session cookie

- `public` `getComment ( )`

  Get the comment

- `public` `setComment ( string $comment )`

  Set the comment of the cookie

- `public` `getCommentUrl ( )`

  Get the comment URL of the cookie

- `public` `setCommentUrl ( string $commentUrl )`

  Set the comment URL of the cookie

- `public` `getPorts ( )`

  Get an array of acceptable ports this cookie can be used with

- `public` `setPorts ( array $ports )`

  Set a list of acceptable ports this cookie can be used with

- `public` `getHttpOnly ( )`

  Get whether or not this is an HTTP only cookie

- `public` `setHttpOnly ( bool $httpOnly )`

  Set whether or not this is an HTTP only cookie

- `public` `getAttributes ( )`

  Get an array of extra cookie data

- `public` `getAttribute ( string $name )`

  Get a specific data point from the extra cookie data

- `public` `setAttribute ( string $name, string $value )`

  Set a cookie data attribute

- `public` `matchesPath ( string $path )`

  Check if the cookie matches a path value

- `public` `matchesDomain ( string $domain )`

  Check if the cookie matches a domain value

- `public` `matchesPort ( int $port )`

  Check if the cookie is compatible with a specific port

- `public` `isExpired ( )`

  Check if the cookie is expired

- `public` `validate ( )`

  Check if the cookie is valid according to RFC 6265

## Methods detail

# `protected static array`
`getInvalidCharacters( )`

Gets an array of invalid cookie characters

#### Returns

`array`
# `public`
`__construct( array $data = array() )`

#### Parameters

$data
  `array`
  $data Array of cookie data provided by a Cookie parser

# `public array`
`toArray( )`

Get the cookie as an array

#### Returns

`array`

#### Implementation of

`Guzzle\Common\ToArrayInterface::toArray()`
# `public string`
`getName( )`

Get the cookie name

#### Returns

`string`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setName( string $name )`

Set the cookie name

#### Parameters

$name
  `string`
  $name Cookie name

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public string`
`getValue( )`

Get the cookie value

#### Returns

`string`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setValue( string $value )`

Set the cookie value

#### Parameters

$value
  `string`
  $value Cookie value

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public string|null`
`getDomain( )`

Get the domain

#### Returns

`string|null`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setDomain( string $domain )`

Set the domain of the cookie

#### Parameters

$domain
  `string`
  $domain

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public string`
`getPath( )`

Get the path

#### Returns

`string`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setPath( string $path )`

Set the path of the cookie

#### Parameters

$path
  `string`
  $path Path of the cookie

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public integer|null`
`getMaxAge( )`

Maximum lifetime of the cookie in seconds

#### Returns

`integer|null`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setMaxAge( integer $maxAge )`

Set the max-age of the cookie

#### Parameters

$maxAge
  `integer`
  $maxAge Max age of the cookie in seconds

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public mixed`
`getExpires( )`

The UNIX timestamp when the cookie expires

#### Returns

`mixed`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setExpires( integer $timestamp )`

Set the unix timestamp for which the cookie will expire

#### Parameters

$timestamp
  `integer`
  $timestamp Unix timestamp

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public mixed`
`getVersion( )`

Version of the cookie specification. RFC 2965 is 1

#### Returns

`mixed`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setVersion( string|integer $version )`

Set the cookie version

#### Parameters

$version
  `string|integer`
  $version Version to set

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public null|boolean`
`getSecure( )`

Get whether or not this is a secure cookie

#### Returns

`null|boolean`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setSecure( boolean $secure )`

Set whether or not the cookie is secure

#### Parameters

$secure
  `boolean`
  $secure Set to true or false if secure

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public null|boolean`
`getDiscard( )`

Get whether or not this is a session cookie

#### Returns

`null|boolean`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setDiscard( boolean $discard )`

Set whether or not this is a session cookie

#### Parameters

$discard
  `boolean`
  $discard Set to true or false if this is a session cookie

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public string|null`
`getComment( )`

Get the comment

#### Returns

`string|null`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setComment( string $comment )`

Set the comment of the cookie

#### Parameters

$comment
  `string`
  $comment Cookie comment

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public string|null`
`getCommentUrl( )`

Get the comment URL of the cookie

#### Returns

`string|null`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setCommentUrl( string $commentUrl )`

Set the comment URL of the cookie

#### Parameters

$commentUrl
  `string`
  $commentUrl Cookie comment URL for more information

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public array`
`getPorts( )`

Get an array of acceptable ports this cookie can be used with

#### Returns

`array`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setPorts( array $ports )`

Set a list of acceptable ports this cookie can be used with

#### Parameters

$ports
  `array`
  $ports Array of acceptable ports

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public boolean`
`getHttpOnly( )`

Get whether or not this is an HTTP only cookie

#### Returns

`boolean`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setHttpOnly( boolean $httpOnly )`

Set whether or not this is an HTTP only cookie

#### Parameters

$httpOnly
  `boolean`
  $httpOnly Set to true or false if this is HTTP only

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public array`
`getAttributes( )`

Get an array of extra cookie data

#### Returns

`array`
# `public null|string`
`getAttribute( string $name )`

Get a specific data point from the extra cookie data

#### Parameters

$name
  `string`
  $name Name of the data point to retrieve

#### Returns

`null|string`
# `public `Guzzle\Plugin\Cookie\Cookie``
`setAttribute( string $name, string $value )`

Set a cookie data attribute

#### Parameters

$name
  `string`
  $name Name of the attribute to set
$value
  `string`
  $value Value to set

#### Returns

``Guzzle\Plugin\Cookie\Cookie``
# `public boolean`
`matchesPath( string $path )`

Check if the cookie matches a path value

#### Parameters

$path
  `string`
  $path Path to check against

#### Returns

`boolean`
# `public boolean`
`matchesDomain( string $domain )`

Check if the cookie matches a domain value

#### Parameters

$domain
  `string`
  $domain Domain to check against

#### Returns

`boolean`
# `public boolean`
`matchesPort( integer $port )`

Check if the cookie is compatible with a specific port

#### Parameters

$port
  `integer`
  $port Port to check

#### Returns

`boolean`
# `public boolean`
`isExpired( )`

Check if the cookie is expired

#### Returns

`boolean`
# `public boolean|string`
`validate( )`

Check if the cookie is valid according to RFC 6265

#### Returns

`boolean|string`
Returns true if valid or an error message if invalid

### Magic methods summary

## Properties summary

`protected array` | $data | # Cookie data
`protected static string` | $invalidCharString | # ASCII codes not valid for for use in a cookie name Cookie names are defined as 'token', according to RFC 2616, Section 2.2 A valid token may contain any CHAR except CTLs (ASCII 0 - 31 or 127) or any of the following separators