On the current tab, I need to insert a cookie with host only set to false
I followed the below code but its set host only always to true
I belive its something to do with domain but how can I create a domain from any given URL to create host only set to false
For e.g https://developer.chrome.com/docs/extensions/reference/api/cookies
let cookieData = {
name :cookieName,
value: cookieValue,
expiration: timeValue,
httpOnly: httpValue,
host: hostValue
}
const insertNewCookie = async (cookieData) => {
let [tab] = await chrome.tabs.query({ active: true, currentWindow: true })
let newExpirationDate
if(cookieData.expiration)
{
newExpirationDate = dayjs(cookieData.expiration).format("YYYY-MM-DD HH:mm:ss")
newExpirationDate = moment(newExpirationDate).unix()
}
let updatedData = {
"name": cookieData.name,
"value": cookieData.value,
"httpOnly": cookieData.httpOnly,
"expirationDate": newExpirationDate,
"url" : tab.url
}
await chrome.cookies.set(updatedData, function (cookie) {
});
}