Options

Sorry page based on number of users

mischamischa Member
In 2.7.0-P1 a new command has been introduced to aFleX
persist size uie [global]
If global is specified, the number of persistent entries in the entire partition is returned.

This means you can for example generate a sorry page based on the max number of active users you want to allow.

For example:
when HTTP_REQUEST { set THRESHOLD "no" set client_ip [IP::client_addr] set persist_entry [persist lookup uie $client_ip] set active_users [persist size uie global] log "persist size = [persist size uie global]" if { $active_users > 1 } { set THRESHOLD "yes" if { $persist_entry eq "" } { HTTP::respond 503 content "Not Available body { font-family: arial; color: black; background: white; } a { color: black; }The site is currently unavailable there are $active_users active users." } elseif { $persist_entry ne "" } { persist uie { $client_ip } 600 } } } when HTTP_RESPONSE { if { $THRESHOLD eq "no" } { persist add uie { $client_ip } 600 } }

Comments

Sign In or Register to comment.