开发者

ER-Diagram : How to manage sessions ? (parallel drupal <-> symfony2)

开发者 https://www.devze.com 2023-03-31 15:53 出处:网络
I am building my app and have been annoyed concerning sessions storage. I am a newbie about sessions. I am working with Symfony2 and MySQL, and as Symfony is storage-agnostic, I am searching into the

I am building my app and have been annoyed concerning sessions storage. I am a newbie about sessions. I am working with Symfony2 and MySQL, and as Symfony is storage-agnostic, I am searching into the Drupal 7 diagram to find a good model.

So I wondered a couple of things :

  • How to manage sessions in an Entity-Relationship diagram ?
  • In drupal 7 diagram, what do sessions->fields mean ?
    • Sessions -> uid (int(10)) -> OK
    • Sessions -> sid (varchar(128)) ?
    • Sessions -> ssid (varchar(128)) ?
    • Sessions -> hostname (varchar(128)) -> OK
    • Sessions -> timestamp (int(11)) -> guessing date of connection
    • Sessions -> cache (int(11)) -> Why only an integer ?
    • Sessions -> session (longblob) -> What do you put inside ?

As I imagined my own diagram, I had 2 tables :

  • Session that stored the sessionId, cookie and establishing date
  • User_Session, association between Sessions and Users, which stores IP address and DateInit.

Why not storing one session by Cookie an开发者_开发知识库d storing also each time the user connects ? If someone could help me understand and help me find the true entity-relationship model...


Description of the session table from Drupal 7 is given in its system_schema() function:

  $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'),
      ),
    ),
  );

But this is not an E-R model. Also, it heavily depends on Drupal own session handling function.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号