pub struct CookieBuilder { /* private fields */ }Expand description
Builder for constructing HTTP cookies.
Provides methods to set various cookie attributes like expiration, domain, path, and security flags before building the final cookie string.
Implementations§
Source§impl CookieBuilder
Implementation for CookieBuilder.
impl CookieBuilder
Implementation for CookieBuilder.
Sourcepub fn parse<C>(cookie: C) -> Self
pub fn parse<C>(cookie: C) -> Self
Parses a Set-Cookie header string into a CookieBuilder.
This method takes a Set-Cookie header string and extracts the various
attributes of a cookie, populating a CookieBuilder instance.
§Arguments
AsRef<str>- TheSet-Cookieheader string to parse.
§Returns
A CookieBuilder instance populated with the parsed cookie attributes.
Sourcepub fn set_expires<E>(&mut self, expires: E) -> &mut Self
pub fn set_expires<E>(&mut self, expires: E) -> &mut Self
Sourcepub fn set_max_age<M>(&mut self, max_age: M) -> &mut Self
pub fn set_max_age<M>(&mut self, max_age: M) -> &mut Self
Sourcepub fn set_domain<D>(&mut self, domain: D) -> &mut Self
pub fn set_domain<D>(&mut self, domain: D) -> &mut Self
Sourcepub fn secure(&mut self) -> &mut Self
pub fn secure(&mut self) -> &mut Self
Sets the Secure flag for the cookie.
This flag indicates that the cookie should only be transmitted over secure (HTTPS) connections.
§Returns
The CookieBuilder instance for method chaining.
Sourcepub fn http_only(&mut self) -> &mut Self
pub fn http_only(&mut self) -> &mut Self
Sets the HttpOnly flag for the cookie.
This flag prevents client-side JavaScript from accessing the cookie.
§Returns
The CookieBuilder instance for method chaining.
Sourcepub fn disable_secure(&mut self) -> &mut Self
pub fn disable_secure(&mut self) -> &mut Self
Explicitly disables the Secure flag for the cookie.
This method explicitly sets the Secure flag to false, which may be useful
for overriding default secure settings or for testing purposes.
§Returns
The CookieBuilder instance for method chaining.
Sourcepub fn disable_http_only(&mut self) -> &mut Self
pub fn disable_http_only(&mut self) -> &mut Self
Explicitly disables the HttpOnly flag for the cookie.
This method explicitly sets the HttpOnly flag to false, which may be useful
for overriding default HttpOnly settings or for testing purposes.
§Returns
The CookieBuilder instance for method chaining.