# Struct actix_web::http::CookieBuilder[−][src]

    pub struct CookieBuilder { /* fields omitted */ }

Structure that follows the builder pattern for building `Cookie` structs.

To construct a cookie:

1. Call `Cookie::build` to start building.
2. Use any of the builder methods to set fields in the cookie.
3. Call finish to retrieve the built cookie.

# Example

    extern crate time;

    use cookie::Cookie;
    use time::Duration;

    let cookie: Cookie = Cookie::build("name", "value")
        .domain("www.rust-lang.org")
        .path("/")
        .secure(true)
        .http_only(true)
        .max_age(Duration::days(1))
        .finish();

## Methods

###

`impl CookieBuilder`

[src]

####

`pub fn new<N, V>(name: N, value: V) -> CookieBuilder where N: Into<Cow<'static, str>>, V: Into<Cow<'static, str>>,`

[src]

Creates a new `CookieBuilder` instance from the given name and value.

This method is typically called indirectly via Cookie::build.

# Example

    use cookie::Cookie;

    let c = Cookie::build("foo", "bar").finish();
    assert_eq!(c.name_value(), ("foo", "bar"));

####

`pub fn expires(self, when: Tm) -> CookieBuilder`

[src]

Sets the `expires` field in the cookie being built.

# Example

    extern crate time;

    use cookie::Cookie;

    let c = Cookie::build("foo", "bar")
        .expires(time::now())
        .finish();

    assert!(c.expires().is_some());

####

`pub fn max_age(self, value: Duration) -> CookieBuilder`

[src]

Sets the `max_age` field in the cookie being built.

# Example

    extern crate time;
    use time::Duration;

    use cookie::Cookie;

    let c = Cookie::build("foo", "bar")
        .max_age(Duration::minutes(30))
        .finish();

    assert_eq!(c.max_age(), Some(Duration::seconds(30 * 60)));

####

`pub fn domain<D>(self, value: D) -> CookieBuilder where D: Into<Cow<'static, str>>,`

[src]

Sets the `domain` field in the cookie being built.

# Example

    use cookie::Cookie;

    let c = Cookie::build("foo", "bar")
        .domain("www.rust-lang.org")
        .finish();

    assert_eq!(c.domain(), Some("www.rust-lang.org"));

####

`pub fn path<P>(self, path: P) -> CookieBuilder where P: Into<Cow<'static, str>>,`

[src]

Sets the `path` field in the cookie being built.

# Example

    use cookie::Cookie;

    let c = Cookie::build("foo", "bar")
        .path("/")
        .finish();

    assert_eq!(c.path(), Some("/"));

####

`pub fn secure(self, value: bool) -> CookieBuilder`

[src]

Sets the `secure` field in the cookie being built.

# Example

    use cookie::Cookie;

    let c = Cookie::build("foo", "bar")
        .secure(true)
        .finish();

    assert_eq!(c.secure(), true);

####

`pub fn http_only(self, value: bool) -> CookieBuilder`

[src]

Sets the `http_only` field in the cookie being built.

# Example

    use cookie::Cookie;

    let c = Cookie::build("foo", "bar")
        .http_only(true)
        .finish();

    assert_eq!(c.http_only(), true);

####

`pub fn same_site(self, value: SameSite) -> CookieBuilder`

[src]

Sets the `same_site` field in the cookie being built.

# Example

    use cookie::{Cookie, SameSite};

    let c = Cookie::build("foo", "bar")
        .same_site(SameSite::Strict)
        .finish();

    assert_eq!(c.same_site(), Some(SameSite::Strict));

####

`pub fn permanent(self) -> CookieBuilder`

[src]

Makes the cookie being built 'permanent' by extending its expiration and max age 20 years into the future.

# Example

    extern crate time;

    use cookie::Cookie;
    use time::Duration;

    let c = Cookie::build("foo", "bar")
        .permanent()
        .finish();

    assert_eq!(c.max_age(), Some(Duration::days(365 * 20)));

####

`pub fn finish(self) -> Cookie<'static>`

[src]

Finishes building and returns the built `Cookie`.

# Example

    use cookie::Cookie;

    let c = Cookie::build("foo", "bar")
        .domain("crates.io")
        .path("/")
        .finish();

    assert_eq!(c.name_value(), ("foo", "bar"));
    assert_eq!(c.domain(), Some("crates.io"));
    assert_eq!(c.path(), Some("/"));

## Trait Implementations

###

`impl Debug for CookieBuilder`

[src]

####

`fn fmt(&self, f: &mut Formatter) -> Result<(), Error>`

[src]

Formats the value using the given formatter. Read more

###

`impl Clone for CookieBuilder`

[src]

####

`fn clone(&self) -> CookieBuilder`

[src]

Returns a copy of the value. Read more

####

`fn clone_from(&mut self, source: &Self)`

1.0.0
[src]

Performs copy-assignment from `source`. Read more

## Auto Trait Implementations

###

`impl Send for CookieBuilder`

###

`impl Sync for CookieBuilder`

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)