简体   繁体   English

储存Cookie电子商务网站

[英]store a cookies e-commerce website

How to store cookies, so that a user would not need to store then next time. 如何存储cookie,以便用户下次无需存储。

I want to make an automation process for storing the cookies for now and for the next time user would access the website. 我现在想进行一个自动化过程来存储cookie,并在下一次用户访问该网站时进行存储。

At the moment I found one example: 目前,我发现了一个例子:

 function readCookie(name)
   {
     var cookieValue = "";
     var search = name + "";
     if (document.cookie.lengt >0)
       {
         offset = document.cookie.indexOf(search);
         if(offset != -1)
           {
             offset +=search.length;
             end = document.cookie.indexOf(";", offset);
             if (end == -1) end = document.cookie.length;
             cookieValue = unescape(document.cookie.substring(offset, end))
            }
         }

      return cookieValue;

    }

can someone explain what is happening here. 有人可以解释这里发生了什么。 As far as I know this only reads the data. 据我所知,这仅读取数据。

Any help would be much of appreciate. 任何帮助将不胜感激。

There are typos in the example you show (lengt?). 您显示的示例中有错别字(lengt?)。 If you continue your search, you will probably find tons of examples on this topic, starting with this site... 如果您继续搜索,则可能会从此站点开始找到有关此主题的大量示例。

To answer partially your question, most of the time the user doesn't even know a cookie is stored, although I see a recent trend to ask permission to the user (is that a new legal obligation?). 为了部分回答您的问题,尽管我看到最近有一种向用户寻求许可的趋势(这是一项新的法律义务?),但大多数情况下用户甚至都不知道存储了cookie。

Your question is a bit vague: you can get code to store and retrieve cookies, but you must call in some JavaScript on your site, know what to store, etc. 您的问题有点含糊:您可以获取用于存储和检索Cookie的代码,但是必须在站点上调用一些JavaScript,知道要存储什么,等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM