At 09:26 AM 6/2/00 +1000, Adam Cassar wrote:
>I was wondering how people are clearing out old Apache::Session's
>
>No timestamp is used on the fields used by Apache::Session, so how do
>we clear the old sessions?
>
>I am not talking about the delete() method to remove a session, as that
>presumes that a user will always leave your site via pre-defined access
>points.
>
Adam,
nobody stops you from adding a timestamp :-)
mysql> describe sessions;
+-----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------------+------+-----+---------+-------+
| id | varchar(16) | | MUL | | |
| modtime | timestamp(14) | YES | | NULL | |
| a_session | blob | YES | | NULL | |
+-----------+---------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
For every access to a session entry mysql will automatically set the first
timestamp field in a row to the current time. We run a cronjob every 15
minutes, which does a:
#!/bin/sh
/usr/local/mysql/bin/mysql -pxxxxx -uxxxx sessions << EOSQL
delete from sessions where time_to_sec(now()) - time_to_sec(modtime) >
60*60;
EOSQL
to clear any session entry older than one hour. Internally the session wil
expire after 30 minutes.
Hope this helps
Tobias