Move segment assignment serverside

To get away from reloading the page with JS and all of the ugliness
that that entails, initial segment assignment is now done serverside and the
segment cookie now contains the name of the segment instead of an int
between 1 and 100.

More than anything, this pull request is a request for feedback on how nicely this implementation will play with batcache and if the security issues around create_function are being properly handled.