34

How do I copy the cookies from one browser in one machine to another? I want to retain the "user details" that the site maintains...

argvargc
  • 341

6 Answers6

15

I wanted to copy my Instagram session to another browser. So I went this way successfully.

On the source browser

  1. Hit F12 / go to Dev Tools
  2. Go to the network tab
  3. Reload the page / hit F5
  4. Scroll up to the very first entry (document http/200)
  5. Click it and go to the headers tab
  6. Find the Cookie header in the Request Headers section and right click / copy value

On the target browser

  1. Go the other browser and hit F12 / go to Dev Tools
  2. Go to the console
  3. Type ''.split(';').forEach(c => document.cookie=c);
  4. Paste your cookie value between the single(!) quotes and hit ENTER
  5. Reload the page / hit F5
8

In Opera browser: Tools->Advanced->Cookies...

In Google Chrome browser:

Install Extension: https://chrome.google.com/webstore/detail/fngmhnnpilhplaeedifhccceomclgfbg and then you can add, delete, and edit your cookies.

To hand over cookies from one browser to another you most likely will have to copy-paste cookie's properties.

izogfif
  • 345
7

Option 1: Use Cookie Editor Chrome extension allows you to backup all cookies from one machine and import into a different one.

Steps to migrate your cookies:

  1. Click on the extension you just installed
  2. Mark all the cookies you want to export
  3. Click the save icon at the bottom
  4. Enter the encryption password
  5. Hit the "Save" button that will appear, and store the file in a known location on your computer
  6. Transfer the file, and just reverse the steps on the destination computer, clicking on Import

Now you have your cookies on a new computer.

Note that the extension only handles a few hundred cookies each time, so if you have a large number of cookies, you won't be able to export all of them at the same time.

Option 2: use the default sync functionality in Google Chrome. It has the additional advantage of keeping not only cookies in sync, but also bookmarks, configuration, and even extensions (on the desktop).

You can also set an encryption password for your data.

6

If you're willing to edit some JavaScript code, you can manually import cookies into Chrome with a custom extension, using the chrome.cookies.set() API.

Since you specify the cookie data manually, this lets you import from any source into Chrome. (I used it to transfer cookies from Safari to Chrome.)

  1. Create a folder for your extension. Add a file named manifest.json with the following contents, and edit to specify which site's cookies you want to change (the extension need to be given permission on those sites):

    {
        "name": "CookieImport",
        "version": "0.0.0",
        "permissions": [
            "cookies",
            "*://*.the-site-whose-cookies-you-want-to-change.com/*"
        ],
        "options_page": "options.html",
        "manifest_version": 2
    }
    
  2. Add a file named options.html with the following. This simply loads the script we're going to create below.

    <!doctype html>
    <html>
      <head></head>
      <body>
        <script src="options.js"></script>
      </body>
    </html>
    
  3. Finally create options.js with this code, and edit the beginning of this script to include the cookies you want to import:

    const allCookies = [
        {
            url: "https://www.example.com",
            name: "__foo",
            value: "bar",
            domain: ".example.com",
            expirationDate: Date.parse("8/19/2021, 8:16:03 PM"),
            // see all possible fields at:
            // https://developer.chrome.com/extensions/cookies#method-set
        },
        // ... more cookies here
    ];
    

    const button = document.createElement("button"); button.type = "button"; document.body.appendChild(button); button.textContent = "Import Cookies"; button.addEventListener("click", () => { for (const c of allCookies) { chrome.cookies.set(c, (res) => { console.log("set", c, res || chrome.runtime.lastError); }); } });

  4. Install the extension via the Load Unpacked button as explained in this tutorial: https://developer.chrome.com/extensions/getstarted#manifest

  5. Click the extension's icon and select Options to open the page we created.
    extension menu

  6. Finally, click the "Import Cookies" button to run the script.

jtbandes
  • 8,960
3

If you are using Internet Explorer use the Import/Export funtion in the File Menu. Other Browsers have similar functions, check the help files.

How to import cookies in IE of computer A to IE of computer B

  • In computer A start up IE.
  • Click on File...Import and Export...
  • In the Wizard window click on Next. Highlight Export Cookies. click on Next.
  • Click on Export to a file.
  • In the window below you can accept the default location of the file
  • cookies.txt or choose your own location using Browse.
  • Now copy that cookies.txt file USB minidrive (whatever).
  • Put the USB minidrive in computer B.
  • Either copy cookies.txt to computer B hard drive or just leave it on the minidrive.
  • In computer B start up IE. Click on File...Import and Export....in the Wizard window
  • click on Next. Highlight Import Cookies. Click on Next.
  • Click on Import from a file. In the window below use Browse to find the cookies.txt file minidrive or on your hard drive if you copied it there. Highlight it. Click on Next.
  • Click on Finish.

Resource from here

subanki
  • 7,784
1

For browser to browser, if you're using Firefox/IE you can use IE Tab Plus, this will seamlessly transfer cookies to IE when launched with the add-on.

Jeff F.
  • 4,443