PHP Classes

DB Structure

Recommend this page to a friend!

      Distributed Session Manager  >  All threads  >  DB Structure  >  (Un) Subscribe thread alerts  
Subject:DB Structure
Summary:problems with expire field
Messages:2
Author:Swen Horvath
Date:2007-04-21 17:46:17
Update:2007-11-21 22:59:20
 

 


  1. DB Structure   Reply   Report abuse  
Picture of Swen Horvath Swen Horvath - 2007-04-21 17:46:17
Hi,

Im experimentting with this class and run into 2 problems:

a, im not sure what sql table structure to use and couldnt find it in docs.
b, ive tried the expire columm with timestamp, time ,varchar, and int but none seem to work corectly. With timestamp the field alsways stays at 0000000000... with varchar and time the field set but updating the time when the session is accessed does not occur...

Any Ideas ?

Thanks for any help!

  2. Re: DB Structure   Reply   Report abuse  
Picture of Sergei Miami Sergei Miami - 2007-11-21 22:59:20 - In reply to message 1 from Swen Horvath
Seems that author does some mistakes in Read and gc functions, in SQL queries, but script is very useful, thanks.

1.
Find line: // Fetch session data from the selected database
And change next string to: $sql = 'SELECT `session_data` FROM `sessions` WHERE `session_id` = \'' . addslashes( $id ) . '\' AND `expires` > UNIX_TIMESTAMP();';

2.
Find line: // Build DELETE query
And change next string to: $sql = 'DELETE FROM `sessions` WHERE `expires` <= UNIX_TIMESTAMP();';

3.
Also, here is SQL table to work with:
CREATE TABLE `sessions` (
`session_id` varchar(40) collate utf8_unicode_ci NOT NULL,
`session_data` longtext collate utf8_unicode_ci NOT NULL,
`expires` int(11) NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

4.
And format of session_hosts.ini:
[n] <-- any number
host = abc <-- hostname
database = abc <-- db name
user = abc <-- db user
password = abc <-- db password
[n+1]
next database...

Woa'la!