General sessions module for web services
-
Async/await
-
Easy custom Storages
-
Stores the values in a
Map<String, Value>
based on serde_json
sessions = { version = "0.1", features = ["memory"] }
use std::sync::Arc;
use sessions::*;
let config = Arc::new(Config {
cookie: CookieOptions::new(),
storage: Arc::new(MemoryStorage::new()),
//storage: Arc::new(RedisStorage::new(RedisClient::open("redis://127.0.0.1")?)),
generate: Box::new(|| nanoid::nanoid!(32)),
verify: Box::new(|sid: &str| sid.len() == 32),
});
let session = Session::new(&config.generate(), 0, config.clone());
session.set::<String>("crate", "sessions".to_string());
let val: Option<String> = session.get("crate");
session.remove("crate");
session.clear();
session.save().await;
session.renew().await;
session.destroy().await;
- Memory
- Redis
- sled
- Memcached
- Mongodb
- PostgreSQL
- MySQL/MariaDB
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.