Struct hyper::header::CookieJar[][src]

pub struct CookieJar<'a> { /* fields omitted */ }

A jar of cookies for managing a session

Example

use cookie::{Cookie, CookieJar};

let c = CookieJar::new(b"f8f9eaf1ecdedff5e5b749c58115441e");

// Add a cookie to this jar
c.add(Cookie::new("key".to_string(), "value".to_string()));

// Remove the added cookie
c.remove("key");

Methods

impl<'a> CookieJar<'a>
[src]

Creates a new empty cookie jar with the given signing key.

The given key is used to sign cookies in the signed cookie jar.

Adds an original cookie from a request.

This method only works on the root cookie jar and is not intended for use during the lifetime of a request, it is intended to initialize a cookie jar from an incoming request.

Adds a new cookie to this cookie jar.

If this jar is a child cookie jar, this will walk up the chain of borrowed jars, modifying the cookie as it goes along.

Removes a cookie from this cookie jar.

Finds a cookie inside of this cookie jar.

The cookie is subject to modification by any of the child cookie jars that are currently borrowed. A copy of the cookie is returned.

Creates a child signed cookie jar.

All cookies read from the child jar will require a valid signature and all cookies written will be signed automatically.

Example

let c = CookieJar::new(b"f8f9eaf1ecdedff5e5b749c58115441e");

// Add a signed cookie to the jar
c.signed().add(Cookie::new("key".to_string(), "value".to_string()));

// Add a permanently signed cookie to the jar
c.permanent().signed()
 .add(Cookie::new("key".to_string(), "value".to_string()));

Creates a child encrypted cookie jar.

All cookies read from the child jar must be encrypted and signed by a valid key and all cookies written will be encrypted and signed automatically.

Example

let c = CookieJar::new(b"f8f9eaf1ecdedff5e5b749c58115441e");

// Add a signed and encrypted cookie to the jar
c.encrypted().add(Cookie::new("key".to_string(), "value".to_string()));

// Add a permanently signed and encrypted cookie to the jar
c.permanent().encrypted()
 .add(Cookie::new("key".to_string(), "value".to_string()));

Creates a child jar for permanent cookie storage.

All cookies written to the child jar will have an expiration date 20 years into the future to ensure they stick around for a long time.

Important traits for Vec<u8>

Calculates the changes that have occurred to this cookie jar over time, returning a vector of Set-Cookie headers.

Return an iterator over the cookies in this jar.

This iterator will only yield valid cookies for this jar. For example if this is an encrypted child jar then only valid encrypted cookies will be yielded. If the root cookie jar is iterated over then all cookies will be yielded.

Auto Trait Implementations

impl<'a> !Send for CookieJar<'a>

impl<'a> !Sync for CookieJar<'a>