有没有办法用jQuery读取标记为HTTPONLY检查的cookie?我有一个名为的cookie wishlist_cookie.
当我尝试
$.cookie('wishlist_cookie');
Run Code Online (Sandbox Code Playgroud)
NULL即使它有值,它也会返回.
vir*_*der -2
你可以尝试用这种方式
var currentSession = [];
var session = function readCookie() {
match = document.cookie.match(new RegExp('TestCookie' + '=([^;]+)'));
if (match) {
var array = match[1].split('&');
for (var i = 0; i < array.length; i++) {
name = array[i].split('=')[0];
value = array[i].split('=')[1];
currentSession.push(setCokiesValue(name, value));
}
}
return currentSession;
};
Run Code Online (Sandbox Code Playgroud)