0

我正在构建我的应用程序,并且对会话存储感到恼火。我是关于会话的新手。我正在使用 Symfony2 和 MySQL,由于 Symfony 与存储无关,我正在搜索Drupal 7 图表以找到一个好的模型。

所以我想知道几件事:

  • 如何在实体关系图中管理会话?
  • 在 drupal 7 图中,会话-> 字段是什么意思?
    • 会话 -> uid (int(10)) -> 确定
    • 会话 -> sid (varchar(128)) ?
    • 会话 -> ssid (varchar(128)) ?
    • 会话->主机名(varchar(128))->确定
    • 会话 -> 时间戳 (int(11)) -> 猜测连接日期
    • 会话 -> 缓存 (int(11)) -> 为什么只有一个整数?
    • Sessions -> session (longblob) -> 你在里面放了什么?

正如我想象自己的图表一样,我有 2 个表格:

  • 存储 sessionId、cookie 和建立日期的会话
  • User_Session,Sessions和Users的关联,存储IP地址和DateInit。

为什么不通过 Cookie 存储一个会话并在每次用户连接时也存储?如果有人可以帮助我理解并帮助我找到真正的实体关系模型......

4

1 回答 1

0

Drupal 7 中会话表的描述在其system_schema()函数中给出:

  $schema['sessions'] = array(
    'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.", 
    'fields' => array(
      'uid' => array(
        'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.', 
        'type' => 'int', 
        'unsigned' => TRUE, 
        'not null' => TRUE,
      ), 
      'sid' => array(
        'description' => "A session ID. The value is generated by Drupal's session handlers.", 
        'type' => 'varchar', 
        'length' => 128, 
        'not null' => TRUE,
      ), 
      'ssid' => array(
        'description' => "Secure session ID. The value is generated by Drupal's session handlers.", 
        'type' => 'varchar', 
        'length' => 128, 
        'not null' => TRUE, 
        'default' => '',
      ), 
      'hostname' => array(
        'description' => 'The IP address that last used this session ID (sid).', 
        'type' => 'varchar', 
        'length' => 128, 
        'not null' => TRUE, 
        'default' => '',
      ), 
      'timestamp' => array(
        'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.', 
        'type' => 'int', 
        'not null' => TRUE, 
        'default' => 0,
      ), 
      'cache' => array(
        'description' => "The time of this user's last post. This is used when the site has specified a minimum_cache_lifetime. See cache_get().", 
        'type' => 'int', 
        'not null' => TRUE, 
        'default' => 0,
      ), 
      'session' => array(
        'description' => 'The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.', 
        'type' => 'blob', 
        'not null' => FALSE, 
        'size' => 'big',
      ),
    ), 
    'primary key' => array(
      'sid',
      'ssid',
    ), 
    'indexes' => array(
      'timestamp' => array('timestamp'), 
      'uid' => array('uid'), 
      'ssid' => array('ssid'),
    ), 
    'foreign keys' => array(
      'session_user' => array(
        'table' => 'users', 
        'columns' => array('uid' => 'uid'),
      ),
    ),
  );

但这不是 ER 模型。此外,它在很大程度上依赖于 Drupal 自己的会话处理功能。

于 2011-08-30T10:22:12.963 回答