kristofvanwoensel
I’ve got multiple applications running on different docker containers. One handles the login of the user, the others all have separate functionalities.
I use OAuth2 to login my users, and save their id in a session cookie. I would like to use this session cookie in my other applications to retrieve the user.
I’ve read that you can share cookies on the same domain. Currently I’ve got this setup in all my applications:
plug Plug.Session,
store: :cookie,
domain: "smiks.online",
key: "_smiks_apps_key",
signing_salt: "********"
My secret_key_base is also similar for all applications.
Even so, the cookies that I saved in my ‘Auth-applications’, are not visible in the other ones. The Auth-app is running on smiks.online, the other applications are running on subdomains (like inschrijvingen.smiks.online). How can I share a cookie between these applications?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex











Showing Posts 1 to 8- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (newest first)
darnahsan
what samesite flag is set on your cookies ? is it
laxorstrict? subdomains will work only in case of it beinglaxbut withstrictdomain needs to match the one in your browser.kristofvanwoensel
I added
without result.
The connection of https://smiks.online contains the cookie:
The connection from extramuros.smiks.online still doesn’t contain any cookie. I also tried with put_resp_cookie without result.
darnahsan
do you see the cookie set in you browser console ? would it be possible for you to share a screenshot or details of what is in your browser ?
dotdotdotPaul
I think you just need to make the domain
.smiks.online(leading dot acts as a wildcard).…Paul
darnahsan
in the new specs the dot is not needed anymore
dotdotdotPaul
Well, that tells you how long it’s been since I tried to do that.
kristofvanwoensel
I’m getting closer to the cause of the problem.
I created a third website called test.smiks.online that stores another cookie, and I was able to open it in the website extramuros.smiks.online.
The problem must be caused by smiks.online, the website that sets the specific cookie I need. The cookie is set (see my post above). In dev-mode (localhost) everything works fine.
I checked every file file, but I’m unable to find the cause. This is my header from the website that needs the cookie, extramuros.smiks.online:
kristofvanwoensel
After trying to comment my code letter by letter, I decided to rebuild the application from scratch with a working result. I kept plugins to a minimum, because I suspect a front-end plugin to be the culprit (if that were possible?)
Anyway, for people looking for the answer, it should work with sharing the same APP_SECRET and having the following session configuration in every application: