【发布时间】:2019-05-06 17:05:02
【问题描述】:
我正在使用 django 创建一个对话聊天机器人。为了保持聊天机器人中的聊天流程,我正在使用 django 会话。但是当我在 iframe 中使用聊天机器人的链接时,它不会存储任何会话并且流程会中断。我想要一个即使在 iframe 中也能帮助维护会话的功能。
对于 iframe
<html>
<head></head>
<body>
<embed style=" width: 384px; height: 525px; margin-right: 0px !important; bottom: 0px; float: right; position: absolute; bottom: 30px; width: 100%;" frameborder="0" scrolling="no" id="iframe" src="http://*********.com/********/*******.html">
</body>
</html>
维护会话的代码
@staticmethod
def extract_data(request, input_data):
from chat import validations
if 'city' not in request.session:
response_data = {'extra': {}, 'data': {}}
response_data['extra']['statement'] = 'Select Car Model which you like to rent?'
response_data['extra']['type'] = 'carmodel'
response_data['data'] = Cars.city_check(request,response_data, input_data)
elif 'veh_name' not in request.session:
response_data = Cars.veh_name_check(request, input_data)
elif 'days' not in request.session:
response_data = validations.days_check(request, input_data)
elif 'phone' not in request.session:
response_data = validations.phone_check(request, input_data)
elif 'email' not in request.session:
response_data = validations.mail_check(request, input_data)
elif 'name' not in request.session:
response_data = validations.name_check(request, input_data, 'Car')
return response_data
【问题讨论】:
-
嗨,有人解决了这个问题吗?
-
我认为这是因为对 3rd 方 cookie 的限制?
-
您能否显示设置这些会话变量的代码。谢谢
-
它与跨域cookie有关。启用浏览器的第三方 cookie 并再次尝试您的 Web 应用程序
标签: django iframe django-sessions