I want to set a cookie using javascript, which would be available for all the tabs in browser.
I have used document.cookie = "tracker=ABC"
Even I have tried to set the path also, but result remained same
document.cookie = "tracker=ABC;path=/"
However, this seems applicable only to the tab where it was set. This cookie is not visible to other tabs in the browser..
Also, I am not very clear with the path concept in cookies. Would be great if someone can tell me about it's use as a secondary answer
Regards,
SAP Learner
So my question is: How can I set a cookie which would be applicable for all the tabs in the browser
A cookie is not linked to a browser tab, but to a domain and its sub-domains.
If you couldn't create a "cross-tab" cookie, it's likely because the domains are different. It's an obvious security rule implemented by all browsers, that prevents domains from accessing other domains cookies.
If the domains are the same, then it works and you can verify it by yourself:
document.cookie = "test"
in the consoledocument.cookie
in the console and you'll be able to see the test
cookie