formalizing cookie saving in segments, so save more message and use encodeURIComponent instead of homemade encoder