0

アプリを作成していますが、セッションの保存に悩まされています。私はセッションの初心者です。私はSymfony2とMySQLを使用していますが、Symfonyはストレージに依存しないため、Drupal7の図を検索して適切なモデルを見つけています。

だから私はいくつかのことを疑問に思いました:

  • 実体関連図でセッションを管理する方法は?
  • drupal 7の図では、sessions-> fieldsはどういう意味ですか?
    • セッション->uid(int(10))-> OK
    • セッション->sid(varchar(128))?
    • セッション->ssid(varchar(128))?
    • セッション->ホスト名(varchar(128))-> OK
    • セッション->タイムスタンプ(int(11))->接続の推測日
    • セッション->キャッシュ(int(11))->なぜ整数だけなのか?
    • セッション->セッション(ロングブロブ)->何を入れますか?

私が自分の図を想像したように、私は2つのテーブルを持っていました:

  • sessionId、cookie、および確立日を保存したセッション
  • User_Session、セッションとユーザー間の関連付け。IPアドレスとDateInitを格納します。

Cookieで1つのセッションを保存し、ユーザーが接続するたびに保存してみませんか?誰かが私を理解し、真の実体関連モデルを見つけるのを手伝ってくれるなら...

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 に答える