Edge或Safari未读取Cookie
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Edge或Safari未读取Cookie相关的知识,希望对你有一定的参考价值。
我遇到了Safari或MS Edge无法读取cookie的问题。它在所有其他浏览器中都运行良好,而不是在这些浏览器中。有没有人遇到过类似的问题?如果是这样,你是如何设法解决的?谢谢。
$('.primary-button.eligibility-button').mousedown(function() {
var selectedCard = $('input[name="cardInterestOption"]:checked').next().text();
var balanceTransferOption = $('input[name="balanceTransferOption"]:checked').next().text().replace(/[a-z]/g,'');
var annualIncome = parseFloat($( "input[name='annualIncome']").val());
var otherIncome = parseFloat($( "input[name='otherIncome']").val());
var totalIncome = annualIncome + otherIncome;
document.cookie = "creditCardSelectorEligibility=" + selectedCard + "; path=/;";
document.cookie = "creditCardBalanceTransfer=" + balanceTransferOption + "; path=/;";
document.cookie = "creditCardTotalIncome=" + totalIncome + "; path=/;";
});
(function() {
var page = "";
var percentage = "NA";
var path = location.pathname;
if(/results/.test(path)){
page = "Success";
var results = "";
var percent = $(".results-banner:eq(0)").text();
if(/[0-9]{2}/.test(percent)){
results = percent.match(/[0-9]{2}/)[0]
}
}
else if(/verify/.test(path)){
page = "Verify";
}
else if(/problem/.test(path)){
page = "Problem";
}
else if(/noteligible/.test(path)){
page = "Not Eligible";
}
else if(/unavailable/.test(path)){
page = "Unavailable";
}
var selectedCard = bt_cookie('yrd_creditCardSelectorEligibility')
var balanceTransferOption = bt_cookie('yrd_creditCardBalanceTransfer')
var totalIncome = bt_cookie('yrd_creditCardTotalIncome')
return page + "|" + selectedCard + "|" + balanceTransferOption + "|" + totalIncome + "|" + results;
})();
答案
我们有时发现的是,页面加载太快而无法创建cookie。所以我们不得不改变Cookies的创建方式。例如,当用户与表单交互时,您可以更改代码以创建Cookie。即:如果选择一个按钮或填写一个字段。在那里捕获cookie,而不是在客户必须单击提交的页面末尾。希望这有道理吗?
以上是关于Edge或Safari未读取Cookie的主要内容,如果未能解决你的问题,请参考以下文章
关闭会话时未删除移动浏览器(chrome、safari)cookie
如何使用 SFSafariViewController 从 iOS Safari 应用程序中读取 Cookie
在 iOS Safari 上的浏览器会话之间未保存 Cookie