Bob_in_Comox
unread,Oct 21, 2010, 11:16:48 PM10/21/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
using 1.87.3
The script to remove old session files assumes a 1 hour expiration.
Sessions with 'remember me' have 30 day expirations. The following
unpacks the session data from the file to check for this (no logging):
EXPIRATION_MINUTES=60
import os, time, stat, cPickle
path = os.path.join(request.folder, 'sessions')
if not os.path.exists(path):
os.mkdir(path)
now = time.time()
for file in os.listdir(path):
filename = os.path.join(path, file)
if os.path.isfile(filename) and
file.startswith(('1','2','3','4','5','6','7','8','9')):
try:
t = os.stat(filename)[stat.ST_MTIME]
f = open(filename, 'rb+')
session_data = cPickle.load(f)
f.close()
except:
continue
try:
expiration = session_data['auth']['expiration']
except:
expiration = EXPIRATION_MINUTES * 60
if (now - t) > expiration:
try:
os.unlink(filename)
except:
pass