I am building my first chrome extension for our website. Not too fancy, i just need to see if user is logged in and if so i would send an ajax request and grab some user data from server and show it in extension popup. At the moment i think, i should check the presence of auth cookie to make sure that user is logged in. I want to, is it a good idea to check the presence of auth cookie for this purpose or should i be taking some other path? This is the code i use to check if user is logged in
isLoggedIn: function () {
var cookie = document.cookie(this.cookieName);
if (console)
console.log(cookie);
if (cookie) {
return true;
}
return false;
},
I know i can't access cookies right away from background process and i have to pass cookie info from content script to background process but i think it explains the idea. Any suggestions?
Edit: I have read this article to send cookie data from content script to popup.js which is in "default_popup" setting in manifest.json file. but i can't seem to pass cookie data back to popup.html and js files referenced there. How can i make it work?
Here is my manifest.json file
{
"name": "Camba TV - Visual Security Made Simple",
"version": "1.0",
"description": "My Cameras on Camba.tv",
"icons": {
"48": "icon48.png",
"128": "icon128.png"
},
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["Cookies.js"]
}
],
"permissions": [
"http://localhost:50477/",
"tabs",
"http://*/*",
"https://*/*",
"cookies"
]
}