我正在加载不同域的iFrame.父站点和iFrame站点都在我的控制之下.我正在使用iFrame.postMessage将消息发布到iFrame.我通过iFrame加载的网站有一个cookie(不是仅限http的cookie).我需要在父网站内读取此cookie.
var opIFrame=document.getElementById('opIFrame').contentWindow;
/**
* periodically invoking the Endpoint at OP for every six seconds
*/
setInterval(function(){
console.log('Sending polling Request From RP Client ... ' + clientId);
document.all.opIFrame.src = endPoint;
opIFrame.postMessage(clientId,"https://localhost:9443/oauth2/loginstatus");
var session=getCookieValue("session_state");
console.log('**session**'+session);
},6000);
function getCookieValue(cookieName) {
var name = cookieName + "=";
var cookies =document.cookie.split(';');
if (!cookies) {
return null;
}
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
if (cookie.indexOf(name) == 0) {
return cookie.substring(name.length, cookie.length);
}
}
return null;
Run Code Online (Sandbox Code Playgroud)
} …
我正在为现有的IDP开发OpenID连接会话管理.在规范中它提到我们应该将会话状态从RP发送到OP.我需要知道会话状态的真正含义.另外我需要知道我应该采取什么样的盐值?
我使用Newcookie()创建了一个cookie,我可以通过浏览器访问它,如下所示.现在我需要阅读cookie
function getCookieValue(cookieName) {
console.log("=====getCookieValue=======");
var name = cookieName + "=";
var cookies = document.cookie.split(';');
console.log("=====ALL cookies======="+cookies);
if (!cookies) {
return null;
}
console.log("=====cookies.length======="+cookies.length);
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
console.log("=====cookies======="+cookies[0]);
if (cookie.indexOf(name) == 0) {
return cookie.substring(name.length, cookie.length);
}
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
但通过使用该方法,我无法读取cookie.请就此向我提出建议.谢谢
我需要一个正则表达式来验证像"foo.com"
. 包含点的单词。我已经尝试了几个,但无法正常工作。
我尝试过的模式:
(\\w+\\.)
(\\w+.)
(\\w.)
(\\W+\\.)
有人可以帮我一个这个。
谢谢,