1#ifndef NEFORCE_NETWORK_HTTP_HTTP_SESSION_HPP__
2#define NEFORCE_NETWORK_HTTP_HTTP_SESSION_HPP__
15NEFORCE_BEGIN_NAMESPACE__
192 void set(
const string& key,
string value);
211 NEFORCE_NODISCARD
bool contains(
const string& key)
const noexcept;
268NEFORCE_END_NAMESPACE__
static datetime now() noexcept
获取当前本地时间
duration< int64_t > seconds
秒持续时间
basic_string_view< char > string_view
字符字符串视图
static http_cookie parse(string_view header)
解析Set-Cookie头
http_cookie_name name
Cookie名称
bool http_only
HttpOnly(禁止JS)
static http_cookie parse(string_view header, string default_domain, string default_path)
解析Set-Cookie头(带默认值)
seconds max_age
Max-Age(-1表示会话Cookie)
void set_expires_from_now(seconds sec)
设置从当前时间开始计算的过期时间
bool is_expired() const noexcept
检查Cookie是否已过期
string to_string() const
序列化为Set-Cookie头
bool secure
Secure(仅HTTPS)
bool is_valid() const noexcept
检查Cookie是否有效
bool contains(const string &key) const noexcept
检查是否包含键
void invalidate() noexcept
无效化会话
string_view get(const string &key) const
获取值
string & operator[](const string &key)
下标操作符
datetime last_access
最后访问时间
bool is_valid() const noexcept
检查会话是否有效
seconds idle_time() const noexcept
获取空闲时间
bool expired(seconds max_inactive=0_s) const noexcept
检查会话是否已过期
void set(const string &key, string value)
设置值
bool remove(const string &key)
删除键值对
void touch() noexcept
更新最后访问时间
seconds max_age
最大空闲时间,默认30分钟
unordered_map< string, string > data
会话数据存储
string to_string() const
序列化为字符串
seconds age() const noexcept
获取会话年龄