Skip to content

Store session creation date in session backends #10

Description

@yoshuawuyts

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.

Screenshot 2020-07-28 13 59 21

Activity

  1. changed the title [-]Store session creation date in sessions[/-] [+]Store session creation date in session backends[/+] on Jul 28, 2020
  2. yoshuawuyts commented on Jul 28, 2020

    @yoshuawuyts
    MemberAuthor

    This view can be recreated by running this branch http-rs/tide#664 and introspecting the database through MongoDB Compass.

  3. jbr commented on Aug 3, 2020

    @jbr
    Member

    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

  4. yoshuawuyts commented on Aug 7, 2020

    @yoshuawuyts
    MemberAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions