Expand description
Sessions handling.
The main feature of this module is the session
function which handles a session. This
function guarantees that a single unique identifier is assigned to each client. This identifier
is accessible through the parameter passed to the inner closure.
§Basic example
Here is a basic example showing how to get a session ID.
use rouille::Request;
use rouille::Response;
use rouille::session;
fn handle_request(request: &Request) -> Response {
session::session(request, "SID", 3600, |session| {
let id: &str = session.id();
// This id is unique to each client.
Response::text(format!("Session ID: {}", id))
})
}
Structs§
- Contains the ID of the session.
Functions§
- Generates a string suitable for a session ID.