Using the cookie value in SQL query sounds like a weird use case for A/B testing. What are you trying to achieve with this?
I think this approach might work for you instead:
- Add a field into your webpart that will store the value for your URL parameter
- On page variant A configure webpart to use "value_A" value
- On page variant B configure webpart to use "value_B" value
- On page open Kentico will serve variant A or B with correct URL parameter in your HTML markup that you can use however you want