For Dear dev crazywoola [ iframe embed issue with user id] #20326

Closed
opened 2026-02-21 20:06:50 -05:00 by yindo · 3 comments
Owner

Originally created by @asrguru20 on GitHub (Nov 14, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • 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

  1. create an agent/ chatflow
  2. embed the iframe to a website
  3. enter a manually user id within the iframe embeded in the website
  4. chat with the floating button chatbot
  5. 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

Originally created by @asrguru20 on GitHub (Nov 14, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/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 1. create an agent/ chatflow 2. embed the iframe to a website 3. enter a manually user id within the iframe embeded in the website 4. chat with the floating button chatbot 5. 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: [](https://youtu.be/kLKn3_tj70s ) 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
yindo added the 🐞 bug label 2026-02-21 20:06:50 -05:00
yindo closed this issue 2026-02-21 20:06:50 -05:00
Author
Owner

@asrguru20 commented on GitHub (Nov 14, 2025):

https://www.youtube.com/watch?v=kLKn3_tj70s

here is the video to see more in details

@asrguru20 commented on GitHub (Nov 14, 2025): https://www.youtube.com/watch?v=kLKn3_tj70s here is the video to see more in details
Author
Owner

@dosubot[bot] commented on GitHub (Nov 14, 2025):

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  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Nov 14, 2025): <!-- Answer --> 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](https://github.com/langgenius/dify-docs/issues/461) and [here](https://github.com/langgenius/dify-docs/issues/422). Your video will be considered for further investigation as this limitation is actively being improved. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3d330326-619e-450c-8705-e5b414da33d4?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3d330326-619e-450c-8705-e5b414da33d4?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3d330326-619e-450c-8705-e5b414da33d4?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3d330326-619e-450c-8705-e5b414da33d4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3d330326-619e-450c-8705-e5b414da33d4?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3d330326-619e-450c-8705-e5b414da33d4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3d330326-619e-450c-8705-e5b414da33d4?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/28224)
Author
Owner

@yangzheli commented on GitHub (Nov 16, 2025):

It seems that if the user_id changes, the app login(passport) should be considered expired.

@yangzheli commented on GitHub (Nov 16, 2025): It seems that if the user_id changes, the app login(passport) should be considered expired.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20326