This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-07-08
Channels
- # announcements (16)
- # beginners (22)
- # calva (3)
- # cider (17)
- # clojure (2)
- # clojure-berlin (1)
- # clojure-denmark (4)
- # clojure-dev (4)
- # clojure-europe (22)
- # clojure-madison (1)
- # clojure-nl (2)
- # clojure-norway (34)
- # clojure-sweden (3)
- # clojure-uk (3)
- # clojurescript (9)
- # datomic (7)
- # deps-new (1)
- # events (1)
- # fulcro (1)
- # hyperfiddle (10)
- # lsp (43)
- # missionary (1)
- # off-topic (27)
- # pedestal (10)
- # polylith (1)
- # reitit (4)
- # releases (1)
- # squint (18)
- # xtdb (8)
Persistent Session Question: What's the easiest way in Electric to identify a user across websocket session keys without making them sign up or making them navigate away from the main Electric endpoint, e.g. to /auth
? Maybe a token in localStorage?
Not for security-sensitive app – just to identify users for about 30 minutes in case they lock their phone and websocket dies & reconnects.
Should I generate an auth token on server, store in localStorage on client & pass it in on component mount?
Put differently, is it possible to store a username cookie from Electric without reloading the page?
Oh cool, I see I can set a cookie from JS, and it shows up on subsequent load in :cookies
(never used JS-side cookies before):
(defn set-cookie! [key value]
; do we need to do some URI encoding here?
(set! (.-cookie js/document) (str key "=" value ";path=/; max-age=86400")))
I'm also working on party games. I use localStorage myself, but cookies have the advantage (or disadvantage) that they can expire after a certain time.
You can make an ID and put it in localstorage and a map on the server. I used this for a chat to get messages of the chat in realtime across tabs and server side streaming of AI generated text across all tabs.