Struct wasm_cookies::cookies::CookieOptions
source · pub struct CookieOptions<'a> {
pub path: Option<&'a str>,
pub domain: Option<&'a str>,
pub expires: Option<Cow<'a, str>>,
pub secure: bool,
pub same_site: SameSite,
}
Expand description
Cookies options (see https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie).
You can create it by calling CookieOptions::default()
.
Fields§
§path: Option<&'a str>
If None
, defaults to the current path of the current document location.
domain: Option<&'a str>
If None
, defaults to the host portion of the current document location.
expires: Option<Cow<'a, str>>
Expiration date in GMT string format.
If None
, the cookie will expire at the end of session.
secure: bool
If true, the cookie will only be transmitted over secure protocol as HTTPS. The default value is false.
same_site: SameSite
SameSite prevents the browser from sending the cookie along with cross-site requests (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#SameSite_attribute).
Implementations§
source§impl<'a> CookieOptions<'a>
impl<'a> CookieOptions<'a>
sourcepub fn with_path(self, path: &'a str) -> Self
pub fn with_path(self, path: &'a str) -> Self
Set the path. The default value is the current path of the current document location.
sourcepub fn with_domain(self, domain: &'a str) -> Self
pub fn with_domain(self, domain: &'a str) -> Self
Set the domain. The default value is the host portion of the current document location.
sourcepub fn expires_at_date(self, date: &'a str) -> Self
pub fn expires_at_date(self, date: &'a str) -> Self
Expires the cookie at a specific date.
date
must be a GMT string (see https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString).
The default behavior of the cookie is to expire at the end of session.
sourcepub fn expires_at_timestamp(self, timestamp: i64) -> Self
pub fn expires_at_timestamp(self, timestamp: i64) -> Self
Expires the cookie at a specific timestamp (in milliseconds, UTC, with leap seconds ignored). The default behavior of the cookie is to expire at the end of session.
sourcepub fn expires_after(self, duration: Duration) -> Self
pub fn expires_after(self, duration: Duration) -> Self
Expires the cookie after a certain duration. The default behavior of the cookie is to expire at the end of session.
sourcepub fn secure(self) -> Self
pub fn secure(self) -> Self
Set the cookie to be only transmitted over secure protocol as HTTPS.
sourcepub fn with_same_site(self, same_site: SameSite) -> Self
pub fn with_same_site(self, same_site: SameSite) -> Self
Set the SameSite value. SameSite prevents the browser from sending the cookie along with cross-site requests (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#SameSite_attribute).
Trait Implementations§
source§impl<'a> Clone for CookieOptions<'a>
impl<'a> Clone for CookieOptions<'a>
source§fn clone(&self) -> CookieOptions<'a>
fn clone(&self) -> CookieOptions<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more