Lotus Dominoアプリケーションで古いが実行可能なJavaScriptを使用して、セッションと永続的なCookieを設定しています。これは、FirefoxとOperaでは正常に機能しますが、IE8では機能しません。IEがページをキャッシュするのを停止するためにhtmlを追加した場合、これは違いがありません。これはコードです:
//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");
これはLotusDomino固有のものではないと思います。最も奇妙なのは、ローカルサーバーに設定したCookieは表示されますが、Firefoxで実行できるように見えるCookieを削除できないことです。これにより、問題が発生します。過去3日間!!
Firefoxデバッガーはエラーを報告せず、IEもデバッグモードではありません。
更新-その日遅く、javascriptコードの問題に対する解決策はありませんが、fromの計算フィールドにある次の式は、毎回セッションCookieを設定します。これは、私が少し好き嫌いの関係にあるネイティブのLotusFormula言語です。ケースは非常にシンプルで100%信頼性があります!
@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)
ps同じコードがMozillaで機能するときに、JavaScriptがIEで機能しないという問題を目にしたのはこれが初めてではありません。私が考えているコードは、IE5では問題ありませんでしたが、以降のバージョンでトリガーされたコードでは機能しなくなりました。 IE、誰かがこの観察に光を当てることができますか?
9月16日、ショッピングカートで多くの進歩を遂げましたが、現在、上記の数式は壊れており、現在のページに応じてCookieを設定していません。FirefoxとOperaでも同じです。ワインとスピリットのカテゴリを表示するとCookieは表示されますが、アクセサリとギフトアイテムは表示されませんが、両方のページタイプに同じコードが使用されています。