Cookies Lotus Domino、Firefox和;歌剧OK

Cookies Lotus Domino、Firefox和;歌剧OK,cookies,lotus-domino,lotus-formula,Cookies,Lotus Domino,Lotus Formula,我在LotusDomino应用程序中使用了一些旧但可行的javascript来设置会话和持久cookie,它在Firefox和Opera中运行良好,但在IE8中不起作用。如果添加html以停止IE缓存页面,但这没有任何区别。代码如下: //Persistant and session cookies for shopping cart and //returning user identification function makeCartID() { var part1 = Math

我在LotusDomino应用程序中使用了一些旧但可行的javascript来设置会话和持久cookie,它在Firefox和Opera中运行良好,但在IE8中不起作用。如果添加html以停止IE缓存页面,但这没有任何区别。代码如下:

//Persistant and session cookies for shopping cart and 
//returning user identification
function makeCartID() {
    var part1 = Math.floor(Math.random()*900) + 1000;
    var part2 = Math.floor(Math.random()*90) + 100;
    return part1.toString() + "-" + part2.toString();
}

//Math.ceil vs Math.floor, document these
function rand(number) {
    return Math.ceil(Math.random()*number);
}

//  Function to return the value of the cookie specified by "name".
//  returns a String object containing the cookie value, or null if cookie not  found
function getCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

// Persistent cookie for unique visitors and latent purchases
function setCustCookies() {
    var thisCookie = getCookie("fwc_shop");
    var myValue = thisCookie;
    if( thisCookie == null) {
        //Setup the random cookie value
//      myValue = new Date();
//      var randNum = rand(100);
        myValue = makeCartID();

        //The expiry date will be 5 years for production
        //Starting with 1 day ...
        var expiryDate = new Date();
    //  expiryDate.setDate(expiryDate.getMonth() + 1);
        expiryDate.setDate(expiryDate.getDay() + 1);
        setCookie("fwc_shop", myValue, expiryDate, "/");
    }     

    // Session cookie for shopping cart, 15 minute default
    var minutes = 15;  //Testing, 60+ for production
    var session = getCookie("fwc_cart");
    var scdt = new Date();
    var sdt = new Date(scdt.getMilliseconds + (minutes * 60 * 1000));

    var sessionVal;
    if(session==null){
       sessionVal=myValue + "=" + scdt.toGMTString() + "_" + rand(100);
    }else{
       sessionVal=session;
    }
    setCookie("fwc_cart", sessionVal, sdt, "/");
}
setCustCookies();


//  Function to delete a cookie. (Sets expiration date to current date/time)
function deleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = getCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
//Worth a try from within script library!!
deleteCookie("fwc_persist");
p、 这不是我第一次看到javascript在IE中不工作的问题,当相同的代码在Mozilla中工作时,我想到的代码在IE5中是可以的,但现在当代码在IE的更高版本中触发时不再工作,有人能解释这一观察结果吗

9月16日
我在我的购物车上取得了很大的进步,但是现在上面的公式被打破了,并且没有根据我在哪一页设置cookie。在Firefox和Opera中也是如此。我可以在查看葡萄酒和烈酒类别时看到cookies,但不查看配件和礼品,但这两种页面类型使用相同的代码。

我已经解决了公式语言cookie代码的问题,经过一些调整后,代码正常工作。最大的问题(未记录)是,因为cookie最初存储在浏览器缓存中,所以只有在刷新页面时,才会在加载的第一个页面上看到http_cookie中的cookie值

解决方案的其余部分围绕使用webqueryopen代理检查http_cookie字段和计算出的cookie字段以及其他与浏览器相关的cgi字段来判断访问是来自搜索机器人还是人类,因为我不需要担心搜索机器人的购物车


我不得不说,这是一个令人沮丧的练习,主要是因为它的文档太少,如果Domino应用程序开发有更好的文档和帮助,那么Domino可能(可能仍然)与浏览器应用程序有更多的相似之处。这并没有让我感到不快,但这一次我有时间去追求它,直到找到一个解决方案,因为这是一个个人项目,而不是客户的有偿工作。

无法看到应用于javascript设置的cookie的cookie值的问题,一旦我了解了如何使用特殊的http_cookie字段来查看已设置的cookie,进度相当快:)
@If(@BrowserInfo("Cookies");""; @Return("Error: cookies not enabled."));
cookieName:="session";
part1 := @Text(@Round(1000 * @Random));
part2 := @Text(@Round(10000 * @Random));
cookieValue:= part1 + "-" + part2;
result:=cookieName + "="+ cookieValue + ";";
@SetHTTPHeader("Set-Cookie"; result)