Create Table Sessions


/ Published in: MySQL
Save to your folder(s)

Saving the IP as Int we save a lot of space and permit do beautibul selects


Copy this code and paste it in your HTML
  1. Create Table Sessions (
  2. session_id INT UNSIGNED NOT NULL AUTOINCREMENT,
  3. ip_address INT UNSIGNED NOT NULL,
  4. session_data TEXT NOT NULL,
  5. PRIMARY KEY (session_id),
  6. INDEX (ip_address)
  7.  
  8. // Insert a new dummy record
  9. INSERT INTO Sessions VALUES (NULL, INET_ATON('192.168.0.2'), 'some session data');
  10.  
  11. //Find all sessions coming from a local subnet
  12. sessin_id,
  13. ip_address as ip_raw,
  14. INET_NTOA(ip_address) as ip,
  15. session_data
  16. FROM Sessions
  17. WHERE ip_address
  18. BETWEEN INET_ATON('192.168.0.1')
  19. AND INET_ATON('192.168.0.255')

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.