我创建了一个模块来验证用户的身份,这要归功于一张卡片,我需要检查他们是否可以访问这个网站。
问题在于Drupal管理会话的方式。它存储数据库中的每个会话并恢复它,因此用户会自动登录,这将导致用户不通过检查过程。
是否有可能停止存储数据库中的会话?
发布于 2017-01-06 00:01:51
在Drupal 8中,可以在/sites/default/services.yml中设置cookie/会话生存期
将cookie_lifetime设置为0意味着用户的会话只会持续到浏览器选项卡关闭为止,所以当他们重新访问站点时,他们需要再次登录。
例如services.yml
parameters:
session.storage.options:
# Default ini options for sessions.
#
# Some distributions of Linux (most notably Debian) ship their PHP
# installations with garbage collection (gc) disabled. Since Drupal depends
# on PHP's garbage collection for clearing sessions, ensure that garbage
# collection occurs by using the most common settings.
# @default 1
gc_probability: 1
# @default 100
gc_divisor: 100
#
# Set session lifetime (in seconds), i.e. the time from the user's last
# visit to the active session may be deleted by the session garbage
# collector. When a session is deleted, authenticated users are logged out,
# and the contents of the user's $_SESSION variable is discarded.
# @default 200000
gc_maxlifetime: 200000
#
# Set session cookie lifetime (in seconds), i.e. the time from the session
# is created to the cookie expires, i.e. when the browser is expected to
# discard the cookie. The value 0 means "until the browser is closed".
# @default 2000000
cookie_lifetime: 0https://stackoverflow.com/questions/41479922
复制相似问题