// use actix_session::{CookieSession, Session}; use actix_web::{web, App, Error, HttpResponse, HttpServer}; async fn index(session: Session) -> Result { // access session data if let Some(count) = session.get::("counter")? { session.set("counter", count + 1)?; } else { session.set("counter", 1)?; } Ok(HttpResponse::Ok().body(format!( "Count is {:?}!", session.get::("counter")?.unwrap() ))) } #[actix_rt::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() .wrap( CookieSession::signed(&[0; 32]) // <- create cookie based session middleware .secure(false), ) .service(web::resource("/").to(index)) }) .bind("127.0.0.1:8088")? .run() .await } //