URL encoding and saving state