pub struct CookieOptions {
pub expire: i64,
pub path: String,
pub domain: String,
pub secure: bool,
pub httponly: bool,
pub samesite: String,
}Expand description
Cookie 配置选项(对齐 PHP think\Cookie::$config)
对齐 PHP 默认配置:
protected $config = [
'expire' => 0,
'path' => '/',
'domain' => '',
'secure' => false,
'httponly' => false,
'samesite' => '',
];Fields§
§expire: i64过期时间(秒)。0 表示会话 cookie(浏览器关闭时删除)。
对齐 PHP 'expire' => 0。
path: StringCookie 有效路径。对齐 PHP 'path' => '/'。
domain: StringCookie 有效域名。对齐 PHP 'domain' => ''。
secure: bool是否仅通过 HTTPS 传输。对齐 PHP 'secure' => false。
httponly: bool是否仅通过 HTTP 访问(JS 不可读)。对齐 PHP 'httponly' => false。
samesite: StringSameSite 策略(Strict / Lax / None / 空)。对齐 PHP 'samesite' => ''。
Implementations§
Source§impl CookieOptions
impl CookieOptions
Sourcepub fn with_expire(expire: i64) -> CookieOptions
pub fn with_expire(expire: i64) -> CookieOptions
创建一个指定过期时间的选项(其他字段使用默认值)
对齐 PHP set($name, $value, $option) 中 $option 为数字时
转换为 ['expire' => $option] 的行为。
Trait Implementations§
Source§impl Clone for CookieOptions
impl Clone for CookieOptions
Source§fn clone(&self) -> CookieOptions
fn clone(&self) -> CookieOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CookieOptions
impl Debug for CookieOptions
Source§impl Default for CookieOptions
impl Default for CookieOptions
Source§fn default() -> CookieOptions
fn default() -> CookieOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CookieOptions
impl RefUnwindSafe for CookieOptions
impl Send for CookieOptions
impl Sync for CookieOptions
impl Unpin for CookieOptions
impl UnsafeUnpin for CookieOptions
impl UnwindSafe for CookieOptions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.