I am creating cookies using javascript with the cookie name starting with SC_
For example, the following are some of the cookie names (there can be hundreds of such cookies):
- SC_item1
- SC_hello
- SC_23
- SC_a
- SC_b
Now I want to read/search all cookies (in Javascript) which are starting with prefix SC_
. How can I do this?
Below is the code I am using to create cookies;
function addToCart(itemid, quantity)
{
var cookieName = "SC_"+itemid;
var value = "hello world";
var exdate=new Date();
exdate.setDate(exdate.getDate() + 365);
var cookieValue= escape(value) + ((exdate==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie = cookieName + "=" + cookieValue;
}