-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store session creation date in session backends #10
Comments
This view can be recreated by running this branch http-rs/tide#664 and introspecting the database through MongoDB Compass. |
Is there a production use case for this or is it just for development/debugging? If the latter, would this be sufficient: use chrono::{DateTime, Utc};
app.with(Before(|mut request: Request<_>| async move {
let session = request.session_mut();
if session.get_raw("created").is_none() {
session.insert("created", Utc::now()).unwrap();
}
request
})); Then it would be available within the serialized json data Alternatively, there's no reason a session store couldn't add additional data to the record |
Yeah that's what I was thinking -- for example MongoDB has a native DateTime object that can be used for serialization. For the default backends we expose it'd probably be useful to track creation time + time of last update. I don't believe MongoDB tracks this itself (it does serialize the creation date in the ID, but it can't be queried for afaict), so making that data available would be be useful. |
I was debugging mongo and couldn't find the creation date in the session store. We should probably track this for all sessions; even if not tracked by UTC it does help with debugging. Perhaps the individual backends provide primitives for this as well that we can use.
Screenshot
I was trying to find from this screenshot which sessions were created today. It doesn't say, heh.
The text was updated successfully, but these errors were encountered: