You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have an Axum server and was using MemoryStore. I just swapped that for PostgresSessionStore. I can see that between browser page reloads that my session is persisting but when I quit my server and restart it then reload the browser again, it seems the session is lost. I can see the async_sessions table in my db has been created.
Here is how I'm configuring it,
// session cookie ------ start
let store = PostgresSessionStore::new(&db_url)
.await
.map_err(|e| {
eprintln!("Database error: {:?}", e);
RestAPIError::InternalServerError
})
.unwrap();
store.migrate().await.unwrap();
store.spawn_cleanup_task(Duration::from_secs(60 * 60));
// I couldn't see how three lines from the async-sqlx-sesssion example were needed with Axum.
// let mut session = Session::new();
// let cookie_value = store.store_session(session).await.unwrap().unwrap();
// let session = store.load_session(cookie_value).await.unwrap();
let secret = random::<[u8; 128]>();
let session_layer = SessionLayer::new(store, &secret)
.with_secure(true)
.with_same_site_policy(SameSite::Strict);
// session cookie ------ end
...
let routes_all = Router::new()
...
.layer(session_layer)
.layer(Extension(app_state))
.fallback_service(routes_static());
In my login route I just update the session like this:
Hi, I have an Axum server and was using
MemoryStore
. I just swapped that forPostgresSessionStore
. I can see that between browser page reloads that my session is persisting but when I quit my server and restart it then reload the browser again, it seems the session is lost. I can see theasync_sessions
table in my db has been created.Here is how I'm configuring it,
In my login route I just update the session like this:
Would you please help me identify the gap?
The text was updated successfully, but these errors were encountered: