$ user登录和访问权限有什么区别?


10

我正在迁移用户,但遇到$ user对象

登录和访问字段之间有什么区别?访问是否随每个页面请求而更新?

Answers:


18

接入领域在Drupal的会话写处理器更新_drupal_session_write。这意味着它可能会在每个页面请求时进行更新。如果您查看源代码,则会发现默认情况下,访问字段仅每180秒更新一次。可以通过设置session_write_intervalDrupal变量来更改此间隔。

// Likewise, do not update access time more than once per 180 seconds.
if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) {
  db_update('users')
    ->fields(array(
    'access' => REQUEST_TIME,
  ))
    ->condition('uid', $user->uid)
    ->execute();
}

7

根据以下字段中的注释user_schema()

access:用户上次访问该网站的时间戳。

login:用户上次登录的时间戳。

因此accesslogin仅当用户实际登录时,才会为每次页面加载更新。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.