Embed preconfigured session variables on a website? #21402

Closed
opened 2026-02-21 20:12:24 -05:00 by yindo · 1 comment
Owner

Originally created by @hacktong9008-art on GitHub (Jan 1, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • 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.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

When I use <script> to embed chatflow into my website, I need to pass the current website's authentication information (cookies). I hope to pass it through session variables. Is this supported?

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @hacktong9008-art on GitHub (Jan 1, 2026). ### 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] 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] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. When I use <script> to embed chatflow into my website, I need to pass the current website's authentication information (cookies). I hope to pass it through session variables. Is this supported? ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the 🙋‍♂️ question label 2026-02-21 20:12:24 -05:00
yindo closed this issue 2026-02-21 20:12:24 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 1, 2026):

Hi @hacktong9008-art! I'm Dosu and I’m helping the dify team.

Dify does not natively support passing cookies or session variables from your website directly to an embedded chatflow via <script> or

@dosubot[bot] commented on GitHub (Jan 1, 2026): <!-- Greeting --> Hi @hacktong9008-art! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> Dify does not natively support passing cookies or session variables from your website directly to an embedded chatflow via <script> or <iframe>. Instead, you can pass user/session data (like user_id, email, etc.) by explicitly setting them in the embedding code. For <script> embedding, set variables in the global window.difyChatbotConfig object under the inputs property, for example: ```js window.difyChatbotConfig = { inputs: { user_id: 'your_user_id', email: 'user@example.com' } } ``` For <iframe> embedding, encode your variables (gzip + base64 + URL-encode) and append them as URL parameters (e.g., sys.user_id) in the iframe src. The chatflow will decode and use these values internally. See the official guide for details and code samples: [Dify embedding documentation](https://docs.dify.ai/en/guides/application-publishing/embedding-in-websites#using-the-%3Ciframe%3E-tag-2) and [discussion](https://github.com/langgenius/dify-docs/issues/490). Dify does not automatically read cookies or session variables from your site; you must extract and pass any needed values explicitly. Authentication for embedded chatflows is handled via share codes and access tokens, not by sharing browser session state. If you need deeper integration, consider synchronizing session state via backend APIs or using JWTs. Let me know if you want a step-by-step example for your specific use case! <!-- 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/2bde6c46-aeba-4979-84c3-d8ad8d74944e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2bde6c46-aeba-4979-84c3-d8ad8d74944e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2bde6c46-aeba-4979-84c3-d8ad8d74944e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2bde6c46-aeba-4979-84c3-d8ad8d74944e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2bde6c46-aeba-4979-84c3-d8ad8d74944e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2bde6c46-aeba-4979-84c3-d8ad8d74944e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2bde6c46-aeba-4979-84c3-d8ad8d74944e?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Dify%20does%20not%20natively%20support%20passing%20cookies%20or%20session%20variables%20from%20your%20website%20directly%20to%20an%20embedded%20chatflow%20via%20%3Cscript%3E%20or%20%3Ciframe%3E.%20Instead%2C%20you%20can%20pass%20user/session%20data%20%28like%20user_id%2C%20email%2C%20etc.%29%20by%20explicitly%20setting%20them%20in%20the%20embedding%20code.%0A%0AFor%20%3Cscript%3E%20embedding%2C%20set%20variables%20in%20the%20global%20window.difyChatbotConfig%20object%20under%20the%20inputs%20property%2C%20for%20example%3A%0A%0A%60%60%60js%0Awindow.difyChatbotConfig%20%3D%20%7B%0A%20%20inputs%3A%20%7B%0A%20%20%20%20user_id%3A%20%27your_user_id%27%2C%0A%20%20%20%20email%3A%20%27user%40example.com%27%0A%20%20%7D%0A%7D%0A%60%60%60%0A%0AFor%20%3Ciframe%3E%20embedding%2C%20encode%20your%20variables%20%28gzip%20%2B%20base64%20%2B%20URL-encode%29%20and%20append%20them%20as%20URL%20parameters%20%28e.g.%2C%20sys.user_id%29%20in%20the%20iframe%20src.%20The%20chatflow%20will%20decode%20and%20use%20these%20values%20internally.%20See%20the%20official%20guide%20for%20details%20and%20code%20samples%3A%20%5BDify%20embedding%20documentation%5D%28https%3A//docs.dify.ai/en/guides/application-publishing/embedding-in-websites%23using-the-%253Ciframe%253E-tag-2%29%20and%20%5Bdiscussion%5D%28https%3A//github.com/langgenius/dify-docs/issues/490%29.%0A%0ADify%20does%20not%20automatically%20read%20cookies%20or%20session%20variables%20from%20your%20site%3B%20you%20must%20extract%20and%20pass%20any%20needed%20values%20explicitly.%20Authentication%20for%20embedded%20chatflows%20is%20handled%20via%20share%20codes%20and%20access%20tokens%2C%20not%20by%20sharing%20browser%20session%20state.%20If%20you%20need%20deeper%20integration%2C%20consider%20synchronizing%20session%20state%20via%20backend%20APIs%20or%20using%20JWTs.%0A%0ALet%20me%20know%20if%20you%20want%20a%20step-by-step%20example%20for%20your%20specific%20use%20case%21)&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/30451)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21402