Soup.Cookie.new
Description: Reference for Soup.Cookie.new

### Function

# Soup Cookienew

#### Declaration [src]

    SoupCookie*
    soup_cookie_new (
      const char* name,
      const char* value,
      const char* domain,
      const char* path,
      int max_age
    )

#### Description [src]

Creates a new `SoupCookie` with the given attributes.

Use `soup_cookie_set_secure()` and `soup_cookie_set_http_only()` if you need to set those attributes on the returned cookie.

If `domain` starts with “.”, that indicates a domain (which matches the string after the “.”, or any hostname that has `domain` as a suffix). Otherwise, it is a hostname and must match exactly.

`max_age` is used to set the “expires” attribute on the cookie; pass -1 to not include the attribute (indicating that the cookie expires with the current session), 0 for an already-expired cookie, or a lifetime in seconds. You can use the constants `SOUP_COOKIE_MAX_AGE_ONE_HOUR`, `SOUP_COOKIE_MAX_AGE_ONE_DAY`, `SOUP_COOKIE_MAX_AGE_ONE_WEEK` and `SOUP_COOKIE_MAX_AGE_ONE_YEAR` (or multiples thereof) to calculate this value. (If you really care about setting the exact time that the cookie will expire, use `soup_cookie_set_expires()`.)

#### Parameters

`name` | `const char*`
| Cookie name.
| The data is owned by the caller of the function.
| The value is a NUL terminated UTF-8 string.
`value` | `const char*`
| Cookie value.
| The data is owned by the caller of the function.
| The value is a NUL terminated UTF-8 string.
`domain` | `const char*`
| Cookie domain or hostname.
| The data is owned by the caller of the function.
| The value is a NUL terminated UTF-8 string.
`path` | `const char*`
| Cookie path, or `NULL`.
| The data is owned by the caller of the function.
| The value is a NUL terminated UTF-8 string.
`max_age` | `int`
| Max age of the cookie, or -1 for a session cookie.

#### Return value

Returns: | `SoupCookie`
| A new `SoupCookie`.
| The caller of the function takes ownership of the data, and is responsible for freeing it.