CherryPy Project Download

Sometimes it may be useful to know how many sessions are active on you cherrypy server. For example you may wish to limit the number of simultaneous logins.

To get the current number of sessions use


For example you might use

class website(object):
    def login(self, user, pass):
        if len(cherrypy.session.cache) > 42:
            return "Sorry to many active users"
            # log in code

The count does not include a new session that was created during the current request.

Note this may only work when using a RAM session. has a patch to cherrypy that allows use of len() on the session object.

Hosted by WebFaction

Log in as guest/cherrypy to create/edit wiki pages