[ic] MySql sessions - expiring

Jon Jensen jon at endpoint.com
Thu Sep 25 21:00:02 EDT 2003

On Thu, 25 Sep 2003, Dorothy Puma wrote:

> I have recently followed Dan Browning's instructions 
> (http://www.icdevgroup.org/~danb/ic_howto_cluster.html) for converting 
> over to MySql based sessions.  It works like a charm.  I checked the 
> archives and found a posting from Mike Heins 
> (http://developer2.akopia.com/archive/interchange-users/2000/msg03202.html) 
> stating that he didn't know if the "expire" would work with this kind of 
> setup, but I didn't see any follow-ups to that.  Does anyone know how to 
> expire the sessions if running in mysql mode?

Hmm ... I think the easiest way would be to add a column to the sessions
table of type TIMESTAMP, name "last_modified" or similar. In MySQL that 
would get updated to the current time every time the row's modified, then 
your session expiration would simply consist of somthing like:

DELETE FROM sessions
WHERE CURRENT_TIMESTAMP - last_modified > INTERVAL 4 hours;

That's untested -- the exact syntax will depend on your version of MySQL.


More information about the interchange-users mailing list