django的settings.py设置session

#如果使用缓存会话后端,则缓存以存储会话数据。
SESSION_CACHE_ALIAS = 'default'                         
# Cache to store session data if using the cache session backend.

#cookie名称,自定义cookie名字
SESSION_COOKIE_NAME = 'sessionid'                       
# Cookie name. This can be whatever you want.

#cookie过期时间,以秒为单位(默认值:2周)。 现在是5分钟。
SESSION_COOKIE_AGE = 60 * 5                             
# Age of cookie, in seconds (default: 2 weeks). Now is 5 minutes.


SESSION_COOKIE_DOMAIN = None                            
# A string like ".example.com", or None for standard domain cookie.

#会话cookie是否应该是安全的(仅限https://)。
SESSION_COOKIE_SECURE = False                           
# Whether the session cookie should be secure (https:// only).

#会话cookie的路径。
SESSION_COOKIE_PATH = '/'                               
# The path of the session cookie.

#是否使用非RFC标准的httpOnly标志(IE,FF3 +,其他)
SESSION_COOKIE_HTTPONLY = True                          
# Whether to use the non-RFC standard httpOnly flag (IE, FF3+, others)

#是否在每个请求上保存会话数据。
SESSION_SAVE_EVERY_REQUEST = False                     
# Whether to save the session data on every request.

#Web浏览器关闭时用户的会话cookie是否过期。
SESSION_EXPIRE_AT_BROWSER_CLOSE = True                  
# Whether a user's session cookie expires when the Web browser is closed.

#用于存储会话数据的模块
SESSION_ENGINE = 'django.contrib.sessions.backends.db'  
# The module to store session data

SESSION_FILE_PATH = None                                
# Directory to store session files if using the file session module. If None, the backend will use a sensible default.

#用于序列化会话数据的类
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'  
# class to serialize session data

猜你喜欢

转载自blog.csdn.net/weixin_40744265/article/details/89472330