@@ 6,9 6,16 @@
* See LICENSE for licensing information.
*/
-use actix_session::{storage::RedisActorSessionStore, Session, SessionMiddleware};
+use actix_session::{
+ config::{PersistentSession, SessionLifecycle, TtlExtensionPolicy},
+ storage::RedisActorSessionStore,
+ Session, SessionMiddleware,
+};
use actix_web::{
- cookie::Key, get, middleware::Logger, web, App, HttpResponse, HttpServer, Responder,
+ cookie::{time::Duration, Key},
+ get,
+ middleware::Logger,
+ web, App, HttpResponse, HttpServer, Responder,
};
use diesel::{
@@ 82,6 89,11 @@ async fn main() -> std::io::Result<()> {
RedisActorSessionStore::new(&redis_url),
Key::from(cookie_key.as_bytes()),
)
+ .session_lifecycle(SessionLifecycle::PersistentSession(
+ PersistentSession::default()
+ .session_ttl(Duration::days(30))
+ .session_ttl_extension_policy(TtlExtensionPolicy::OnStateChanges),
+ ))
.build(),
)
.service(ping)