Although servers can write named cookies one at a time, JavaScript cannot. You can set an individual named cookie with the statement, document.cookie=’cookiename=xxxx’, but when you retrieve document.cookie, you get a string consisting of all of the cookies.
Currently, the only way to retrieve an individual cookie is to search through the entire set of cookies obtained from document.cookie. Consequently, it helps to add a prefix or suffix to the names of your cookies with little-used characters. This makes them easy to find with IndexOf().
Leave a Reply
You must be logged in to post a comment.