Correctly handle invalid cookie values and names