pub struct Cookie {
pub name: String,
pub value: String,
pub path: Option<String>,
pub domain: Option<String>,
pub max_age: Option<Duration>,
pub secure: bool,
pub http_only: bool,
pub same_site: Option<SameSite>,
/* private fields */
}Expand description
A cookie to be sent with a response.
Defaults are the safe ones — HttpOnly, SameSite=Lax, path / — so a
session cookie is hardened unless the application opts out.
Fields§
§name: String§value: String§path: Option<String>§domain: Option<String>§max_age: Option<Duration>§secure: bool§http_only: bool§same_site: Option<SameSite>Implementations§
Source§impl Cookie
impl Cookie
pub fn new(name: impl Into<String>, value: impl Into<String>) -> Self
Sourcepub fn forget(name: impl Into<String>) -> Self
pub fn forget(name: impl Into<String>) -> Self
A cookie that instructs the browser to drop an existing one.
pub fn path(self, path: impl Into<String>) -> Self
pub fn domain(self, domain: impl Into<String>) -> Self
pub fn max_age(self, age: Duration) -> Self
pub fn secure(self, secure: bool) -> Self
pub fn http_only(self, http_only: bool) -> Self
pub fn same_site(self, same_site: SameSite) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cookie
impl RefUnwindSafe for Cookie
impl Send for Cookie
impl Sync for Cookie
impl Unpin for Cookie
impl UnsafeUnpin for Cookie
impl UnwindSafe for Cookie
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more