Skip to main content

session_cookie

Function session_cookie 

Source
pub fn session_cookie(
    session_id: &str,
    cookie_name: &str,
    ttl_secs: u64,
) -> String
Expand description

Build a Set-Cookie header value that stores session_id in cookie_name with HttpOnly, SameSite=Lax, Path=/, and Max-Age.

ยงExample

use rust_web_server::{session, header::Header};

let value = session::session_cookie("abc123", "sid", 3600);
// response.headers.push(Header { name: "Set-Cookie".to_string(), value });