dongtuo7364 2011-08-09 21:02
浏览 6

Cookie名称以预定义值开头

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;
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源