[][src]Crate actix_sled_session

Actix Sled Session

An Actix Web Session Backend using the Sled embedded database

This session backend sets an cookie with a unique ID for each incoming request that doesn't already have an ID set, and uses that ID as a key to look up session data from a Sled tree.


Update your Cargo.toml

actix = "0.8"
actix-sled-session = "0.1"
actix-web = "1.0"

Use it in your project

use actix::System;
use actix_web::{web, App, HttpServer};
use actix_sled_session::{Session, SledSession};

fn index(session: Session) -> String {
    if let Ok(Some(item)) = session.get::<usize>("item") {
        println!("item, {}", item);
        return format!("Got item, {}", item);

    let _ = session.set::<usize>("item", 3);
    String::from("Set item!")

let sys = System::new("example");
let session_backend = SledSession::new_default()?;

HttpServer::new(move || {
        .route("/", web::get().to(index))

// Commented to prevent never-ending tests
// sys.run()?;



The high-level interface you use to modify session data.


The session middleware