---
title: Cookie
summary: A Cookie represents an HTTP cookie as sent in the Set-Cookie header of an HTTP response or the Cookie header of an HTTP request.
url: https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/fsthttp/struct.Cookie/
---

**Kind:** Struct  
**Module:** [fsthttp](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/fsthttp/)  
**Package:** compute-sdk-go v1.11.0  
**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/fsthttp/cookie.go#L22

```go
type Cookie struct {
	Name  string
	Value string

	Path       string
	Domain     string
	Expires    time.Time
	RawExpires string

	MaxAge int
	Secure bool

	HttpOnly bool

	SameSite SameSite
	Raw      string
	Unparsed []string
}
```

A Cookie represents an HTTP cookie as sent in the Set-Cookie header of an
HTTP response or the Cookie header of an HTTP request.

See https://tools.ietf.org/html/rfc6265 for details.

## Fields

### Name

**Type:** `string`

### Value

**Type:** `string`

### Path

**Type:** `string`

optional

### Domain

**Type:** `string`

optional

### Expires

**Type:** `time.Time`

optional

### RawExpires

**Type:** `string`

for reading cookies only

### MaxAge

**Type:** `int`

MaxAge=0 means no 'Max-Age' attribute specified.
MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
MaxAge>0 means Max-Age attribute present and given in seconds

### Secure

**Type:** `bool`

### HttpOnly

**Type:** `bool`

### SameSite

**Type:** `SameSite`

### Raw

**Type:** `string`

### Unparsed

**Type:** `[]string`

Raw text of unparsed attribute-value pairs

## Methods

### String

**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/fsthttp/cookie.go#L185

```go
func (c *Cookie) String() string
```

String returns the serialization of the cookie for use in a Cookie
header (if only Name and Value are set) or a Set-Cookie response
header (if other fields are set).
If c is nil or c.Name is invalid, the empty string is returned.

**Returns**

`string`

### Valid

**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/fsthttp/cookie.go#L249

```go
func (c *Cookie) Valid() error
```

Valid reports whether the cookie is valid.

**Returns**

`error`
