Django session global配置

 

 

from django.conf import global_settings

# Cookie name. This can be whatever you want.
SESSION_COOKIE_NAME = 'sessionid'
# Age of cookie, in seconds (default: 2 weeks).
SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
# Whether to save the session data on every request.
SESSION_SAVE_EVERY_REQUEST = True  # 每次请求后更新超时时间
# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = True # 关闭浏览器cookie就失败
# The module to store session data
SESSION_ENGINE = 'django.contrib.sessions.backends.db'  
# session 保存的位置
# 默认是数据库  缓存  缓存+数据库  文件  加密cookie
# 可以定位到db文件的位置,里边有除了db之外的其他保存方式
from django.contrib.sessions.backends import db

  

posted @ 2021-08-23 15:14  Star-Hitian  阅读(31)  评论(0编辑  收藏  举报