I am starting to write code for testing A / B in a Grails web application. I want to make sure that requests from the same IP address always see the same options. Instead of storing the IP-> option map, is it enough to simply translate the IP address into an integer by deleting the dots, and then use this as a seed for a random number generator? The following happens in the Grails filter:
def ip = request.remoteAddr def random = new Random(ip.replaceAll(/\./, '').toInteger()) def value = random.nextBoolean() session.assignment = value
I know that identifying users by IP address is not reliable, and I will also use session variables / cookies, but this seems useful for the case when we have a new session and the cookie is not set (or the user has cookies disabled.)
source share