Jump to content


Photo

How to store other languages (unicode) in cookies and get it back again

cookies unicode

  • Please log in to reply
1 reply to this topic

#1 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5177 posts

Posted 10 July 2014 - 05:33 AM

How to store other languages (unicode) in cookies and get it back again
var cookieValue = document.getElementsByTagName('input')[0].value;
document.cookie = "lboxcook=" + encodeURIComponent(cookieValue);

function get_cookie(cookie_name) {
var results = document.cookie.match ('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
return results ? decodeURIComponent(results[2]) : null;
}
Farshad, I think in the future, by default, you can use this approach when saving cookies
 
Sincerely.

 


  • 2

#2 Juugii

Juugii

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 30 May 2018 - 12:27 AM

Unicode write read cookie
  
uses System.NetEncoding
 
//write cookie
UniApplication.Cookies.SetCookie(CookieName,CookieValue, 0, False, False, '');
 
//read cookie
strval=TNetEncoding.Base64.decode(UniApplication.Cookies[CookieName]);

  • 0





Also tagged with one or more of these keywords: cookies, unicode

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users