For Dear dev crazywoola [ iframe embed issue with user id]
Self Checks
- [x] I have read the Contributing Guide and Language Policy.
- [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [x] I have searched for existing issues search for existing issues, including closed ones.
- [x] I confirm that I am using English to submit this report, otherwise it will be closed.
- [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
- [x] Please do not modify this template :) and fill in all the required fields.
Dify version
1.10.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
- create an agent/ chatflow
- embed the iframe to a website
- enter a manually user id within the iframe embeded in the website
- chat with the floating button chatbot
- go and change the user id then you will see the chatbot always returns the first time use id it gets no matter if you switch the user of the website or refresh the page and restart the chat window message
here is a video presentaion: Note: this issue introduced right after dify 1.9.1 so in dify 19.2 and 1.10.0 this issue exist
I remember once this issue was in old version and solved
for a such use like me using dify in my wordpress for logged in users is big matter
I hope this issue will soon be ok
✔️ Expected Behavior
the new user id from chatbot iframe should be passed after a user switch or page refreshes
❌ Actual Behavior
chatbot always returns the first user id it interact
https://www.youtube.com/watch?v=kLKn3_tj70s
here is the video to see more in details
Thanks for sharing the video—it's helpful for understanding the issue.
This behavior is due to how Dify's iframe embed manages session state: it uses localStorage keyed by both appId and userId, so if the iframe isn't reloaded with a new, properly encoded user ID (as the sys.user_id URL parameter), the chatbot will keep using the initial user context even after a user switch or page refresh. The iframe embed doesn't have a built-in way to reset or clear session state when switching users; session isolation relies on updating the iframe src with a new encoded sys.user_id. Cross-origin localStorage can't be cleared from the parent page, so reloading the iframe is the recommended workaround for now. Make sure to encode the user ID by GZIP compressing, Base64 encoding, and URI encoding it—simple encoding won't work. See more details and code examples here and here.
Your video will be considered for further investigation as this limitation is actively being improved.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
It seems that if the user_id changes, the app login(passport) should be considered expired.