Ferreteria/sql/user session: Difference between revisions

From Woozle Writes Code
Jump to navigation Jump to search
(New page: ==About== * '''History''': ** '''2009-06-18''' design started - first draft, not sure concept is right * '''Relations''': Each {{vbzcart|table|shop_client}} has one or more {{vbzcart|table...)
 
(notes on usage)
Line 3: Line 3:
** '''2009-06-18''' design started - first draft, not sure concept is right
** '''2009-06-18''' design started - first draft, not sure concept is right
* '''Relations''': Each {{vbzcart|table|shop_client}} has one or more {{vbzcart|table|shop_session}}s
* '''Relations''': Each {{vbzcart|table|shop_client}} has one or more {{vbzcart|table|shop_session}}s
* '''Usage''':
** For now, we will be treating each "client" as having its own session which never expires. Having a separate class for the session, though, lets us decouple these things later on if we want to.
** There should eventually be an "empty cart" button; if the user has not logged in, then that button should start a new session rather than clearing the cart for the current session.
* '''Fields''':
** '''WhenClosed''': if not NULL, then this session should not be reused (might be a different user returning to their cart, or might be the same user -- if no login, we have no way of telling, so take safest choice). If this session is accessed after the time of WhenExpires, code should manually set WhenClosed to NOW().
==SQL==
==SQL==
<section begin=sql /><mysql>DROP TABLE IF EXISTS `shop_session`;
<section begin=sql /><mysql>DROP TABLE IF EXISTS `shop_session`;
Line 10: Line 15:
   `Token`        VARCHAR(31)  COMMENT "session identifier passed as cookie = hash(ID + WhenCreated)",
   `Token`        VARCHAR(31)  COMMENT "session identifier passed as cookie = hash(ID + WhenCreated)",
   `WhenCreated`  DATETIME    COMMENT "when session was created",
   `WhenCreated`  DATETIME    COMMENT "when session was created",
   `WhenExpires`  DATETIME    COMMENT "when session will (or did) expire",
   `WhenExpires`  DATETIME    COMMENT "when session was due to expire",
  `WhenClosed`  DATETIME    COMMENT "when the session was closed",
   PRIMARY KEY(`ID`),
   PRIMARY KEY(`ID`),
   UNIQUE KEY(`Token`)
   UNIQUE KEY(`Token`)
  ) ENGINE = MYISAM;</mysql>
  ) ENGINE = MYISAM;</mysql>
<section end=sql />
<section end=sql />

Revision as of 15:35, 21 June 2009

About

  • History:
    • 2009-06-18 design started - first draft, not sure concept is right
  • Relations: Each Template:Vbzcart has one or more Template:Vbzcarts
  • Usage:
    • For now, we will be treating each "client" as having its own session which never expires. Having a separate class for the session, though, lets us decouple these things later on if we want to.
    • There should eventually be an "empty cart" button; if the user has not logged in, then that button should start a new session rather than clearing the cart for the current session.
  • Fields:
    • WhenClosed: if not NULL, then this session should not be reused (might be a different user returning to their cart, or might be the same user -- if no login, we have no way of telling, so take safest choice). If this session is accessed after the time of WhenExpires, code should manually set WhenClosed to NOW().

SQL

<section begin=sql /><mysql>DROP TABLE IF EXISTS `shop_session`; CREATE TABLE `shop_session` (

 `ID`           INT NOT NULL AUTO_INCREMENT,
 `ID_Client`    INT NOT NULL COMMENT "shop_client.ID",
 `Token`        VARCHAR(31)  COMMENT "session identifier passed as cookie = hash(ID + WhenCreated)",
 `WhenCreated`  DATETIME     COMMENT "when session was created",
 `WhenExpires`  DATETIME     COMMENT "when session was due to expire",
 `WhenClosed`   DATETIME     COMMENT "when the session was closed",
 PRIMARY KEY(`ID`),
 UNIQUE KEY(`Token`)
) ENGINE = MYISAM;</mysql>

<section end=sql />