ER-диаграмма: как управлять сессиями?(параллельный друпал <-> symfony2) - PullRequest
0 голосов
/ 29 августа 2011

Я создаю свое приложение, и меня раздражает хранение сессий.Я новичок в сессиях.Я работаю с Symfony2 и MySQL, и поскольку Symfony не зависит от хранилища, я ищу диаграмму Drupal 7 , чтобы найти хорошую модель.

Так что яИнтересно несколько вещей:

  • Как управлять сеансами в диаграмме Entity-Relationship?
  • В диаграмме drupal 7, что означают сеансы-> поля?
    • Сеансы -> uid (int (10)) -> ОК
    • Сеансы -> sid (varchar (128))?
    • Сеансы -> ssid (varchar (128)))?
    • Сеансы -> имя хоста (varchar (128)) -> OK
    • Сеансы -> метка времени (int (11)) -> угадывание даты соединения
    • Сеансы -> кеш (int (11)) -> Почему только целое число?
    • Сеансы -> сессия (longblob) -> Что вы помещаете внутрь?

Когда я представлял свою собственную диаграмму, у меня было 2 таблицы:

  • Сеанс, в котором сохранены ID сессии, cookie и дата установления
  • User_Session, связь между Сеансами и Пользователями, которая хранитIP-адрес и DateInit.

Почему бы не сохранить один сеанс с помощью Cookie, а также сохранять при каждом подключении пользователя?Если бы кто-то мог помочь мне понять и помочь мне найти истинную модель сущности-отношения ...

1 Ответ

0 голосов
/ 30 августа 2011

Описание таблицы сеансов из 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.

...