my problem is, that i want to limit the number of users that can simultaneously be logged in my application (this value is stored in the database). first i tried to do that
First I was thinking of counting users which logged in given period, but this can be inaccurate.
I think you could cache user id and time of his last action. Then you could write filter, that on every action updates this cache if user is logged in. Then you could just count items that are in the cache. If your cache would be small, you could also iterate over it and remove users that are inactive for eg. five minutes (or any other, like session expiration - btw: sessionId
could also be stored there, so you could check if that session is still valid). If cache big, scheduled job could take care of it.