pub fn build_cookie_string(
name: &str,
value: &str,
options: CookieOptions,
) -> StringExpand description
中文 | English 从 CookieOptions 构建完整的 Set-Cookie 字符串 | Build complete Set-Cookie string from CookieOptions
§参数 | Parameters
name: Cookie 名称 | Cookie namevalue: Cookie 值 | Cookie valueoptions: Cookie 选项(Domain、Path、Max-Age 等)| Cookie options
§返回 | Returns
String: 完整的 Set-Cookie 头值
§示例 | Example
use sa_token_adapter::{utils::build_cookie_string, CookieOptions, SameSite};
let cookie = build_cookie_string("session", "abc123", CookieOptions {
domain: Some("example.com".to_string()),
path: Some("/".to_string()),
max_age: Some(3600),
http_only: true,
secure: true,
same_site: Some(SameSite::Strict),
});
// 结果: "session=abc123; Domain=example.com; Path=/; Max-Age=3600; HttpOnly; Secure; SameSite=Strict"