I need to set a cookie with javascript which I’m doing this with the following command:
document.cookie = name+"="+value;
My problem is that value is a string, which can contain any unicode-character.
Is there a function which automatically replaces special characters (like ;) – and if not, which characters are forbidden?
Something like the “encodeURIComponent()”-Function for Get-Parameters would be perfect
You should use
window.escape.It also has
window.unescapecounterpart.Upd.
It may make some sense to use base64 encoding/decoding prior to escaping in order not to suffer that much from unicode characters expenditure by
window.encode.