Trying to use sessions with lacinia-pedestal

31 views
Skip to first unread message

Hadil Sabbagh

unread,
Sep 8, 2019, 5:40:32 PM9/8/19
to pedestal-users
Hi I am trying to add sessions to my lacinia-pedestal interceptor stack. I know that the Ring middleware session handler is being added to the interceptor queue, but I don't know how to place data into a session. Can anyone point me in the right direction?

Thanks,
Hadil


Paul deGrandis

unread,
Sep 9, 2019, 7:18:36 AM9/9/19
to pedestal-users
Hi Hadil,

Thanks for using Pedestal and reaching out to the community!
I'm not sure I'm remembering correctly, but they should work exactly how they work with Ring Middleware.  The request will have a `:session` key/entry.  You write session information via adding a `:session` entry in your response map (or using the Ring util/response functions for building that map) -- setting the value to `nil` here will reset the session.

Follow up here with more questions and share what you find.

Cheers,
Paul

Daniel De Aguiar

unread,
Sep 9, 2019, 8:33:24 AM9/9/19
to pedestal-users
Hi Hadil,

I saw your comment in the Clojurians #pedestal Slack channel and see it was due to how you constructed your service map. Glad you were able to work it out!

/dan

Hadil Sabbagh

unread,
Sep 9, 2019, 10:11:28 AM9/9/19
to pedestal-users
Thanks for both of your inputs! I am putting :session/key and :session in the :response map but it does not appear in the session store on my browser.

Any thoughts?

Hadil Sabbagh

unread,
Sep 9, 2019, 12:59:54 PM9/9/19
to pedestal-users
lacinia-pedestal seems to change what goes into responses...

Paul deGrandis

unread,
Sep 10, 2019, 6:57:39 AM9/10/19
to pedestal-users
Hi Hadil,

In the past, I've often just written my own interceptor to control session information however I like (and placing session information in the context instead of the request/response).
In this particular case, you may end up writing two interceptors:
 1. An interceptor that will see your response map before lacina (and smuggle the :session onto the context)
 2. An interceptor that performs the same logic/body as the current session, but places request session info in the request-map, and updates to session from the context (instead of the response map).

The other option is to file an issue with lacina to preserve session info in the response.

Cheers,
Paul

Hadil Sabbagh

unread,
Sep 10, 2019, 10:51:07 AM9/10/19
to pedestal-users
Thank you Paul. I think I understand how to write these two interceptors. How do I put in the session Ring interceptor?
Reply all
Reply to author
Forward
0 new messages