简体   繁体   English

如何为 flask 创建独特的浏览器会话? [等候接听]

[英]How to make unique browser sessions for flask? [on hold]

I have a Flask Application running in a windows server.我有一个 Flask 应用程序在 windows 服务器中运行。

Problem: When multiple instances are used from browser or when there are multiple users using the application there are overlap of datas.问题:当从浏览器使用多个实例或有多个用户使用应用程序时,数据会重叠。 In short, it is not creating unique sessions for unique access to the application.简而言之,它不是为对应用程序的唯一访问创建唯一会话。

Can you please help how to make them unique for unique users?您能否帮助如何使它们对独特的用户独一无二?

Use 'User Loader' function.使用“用户加载程序”function。 Add this to your models.py: This will load the user from which you are logged in:将此添加到您的 models.py 中:这将加载您登录的用户:

from app import login

@login.user_loader
def load_user(id):
    return User.query.get(int(id))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM