Git Product home page Git Product logo

Comments (5)

nikolap avatar nikolap commented on July 17, 2024

Ah you'd need to add readers to the cookie store implementation for that. We don't provide that by default because people may choose to use different time libraries, but I get why it's problematic... any thoughts @yogthos . Here's a sample snippet from a project I'm using. Of course you can replace tick with your choice of date-time library or just native Java.

(defn wrap-base
  [{:keys [cookie-opts]}]
  (let [{:keys [cookie-secret cookie-name cookie-default-max-age]} cookie-opts
        cookie-store (session.cookie/cookie-store {:key     (.getBytes ^String cookie-secret)
                                                   :readers {'inst                 (fn [x]
                                                                                     (some-> x (tick/parse) (tick/inst)))
                                                             'time/zoned-date-time #'tick/zoned-date-time}})]
    (fn [handler]
      (cond-> handler
              true (session/wrap-session {:store        cookie-store
                                          :cookie-name  cookie-name
                                          :cookie-attrs {:max-age cookie-default-max-age}})
              true (cookies/wrap-cookies)))))

from kit.

nikolap avatar nikolap commented on July 17, 2024

Another option now that I think about it is to use Java's new date/time APIs instead... maybe that would be a sane default

from kit.

yogthos avatar yogthos commented on July 17, 2024

We could add Java default date/time API for cookies, but does seem like a fairly specific use case. It would definitely be good to add this in documentation though.

from kit.

jpe90 avatar jpe90 commented on July 17, 2024

@nikolap thanks a bunch! I was able to get it working with that info and example.

I'll leave this open since you guys are deciding on adding a default or just noting this in docs, but feel free to close it whenever.

from kit.

yogthos avatar yogthos commented on July 17, 2024

Added an example under cookie session documentation.

from kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.