use axum::{routing::get, Router}; use axum_session::{Session, SessionConfig, SessionLayer, SessionNullPool, SessionStore}; use tokio::net::TcpListener; #[tokio::main] async fn main() { //This Defaults as normal Cookies. //To enable Private cookies for integrity, and authenticity please check the next Example. let session_config = SessionConfig::default().with_table_name("sessions_table"); // create SessionStore and initiate the database tables let session_store = SessionStore::::new(None, session_config) .await .unwrap(); // build our application with some routes let app = Router::new() .route("/greet", get(greet)) .layer(SessionLayer::new(session_store)); let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap(); axum::serve(listener, app).await.unwrap(); } async fn greet(session: Session) -> String { let mut count: usize = session.get("count").unwrap_or(0); count += 1; session.set("count", count); count.to_string() }