ThatMexikan
ThatMexikan

Reputation: 13

Overwriting Cookies Using Chrome Extension API

So I'm planning to manipulate some Facebook cookies in order to made a security extension for Chrome. However I'm having issues in trying to overwrite the cookie. Below is a sample cookie and how it is stored in Chrome:

Name:                   c_user
Content:                0000000000
Domain:                 .facebook.com
Path:                   /
Send for:               Secure connections only
Accessible to script:   Yes
Created:                Saturday, June 8, 2013 11:33:35 PM
Expires:                When the browsing session ends

This is the code that currently isn't working in attempting to overwrite the cookie above:

    chrome.cookies.set({ "url": "https://.facebook.com", 
                         "domain" : "https://.facebook.com", 
                         "name" : "c_user", 
                         "value" : "1111111111", 
                         "secure" : true});

The code is placed inside the extension's default popup and it is executed once a button is clicked. I am able to remove the cookie without any hassle though using:

chrome.cookies.remove({ "url": "https://.facebook.com", 
                        "name" : "c_user"});

Has anybody encountered this before?

Upvotes: 1

Views: 1483

Answers (1)

user149341
user149341

Reputation:

Your domain should be a domain, not a URL. Try:

chrome.cookies.set({
     "url": "https://facebook.com", 
     "domain" : ".facebook.com", 
     etc...                
});

Upvotes: 2

Related Questions