Rob--W / cookie-manager

Cookie Manager for Firefox (Desktop/Android), Chrome. Supports viewing and editing of cookies and private cookies.
Mozilla Public License 2.0
105 stars 24 forks source link

Importing cookies didn't work as it seems... 🤔 #16

Closed AnhDQHE181109 closed 6 years ago

AnhDQHE181109 commented 6 years ago

Ok, SO, I tried to export the cookies from my Facebook session, and then import them to the private browsing mode. But well... It didn't work :v I still don't understand why... When I imported it, and then click cancel to go back, nothing was applied :< Care to have some work arounds?

Rob--W commented 6 years ago

Could you paste an example of the JSON file that you are trying to import? Feel free to completely redact the values of the cookies; I am only interested in the cookie structure and keys. One of the known ways to fail importing is #15, which I intend to fix.

AnhDQHE181109 commented 6 years ago

{ "cookieManagerVersion": "1.4", "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0", "cookies": [ { "name": "datr", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": true, "session": false, "expirationDate": 1594469240, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "locale", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": false, "session": false, "expirationDate": 1532002040, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "sb", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": true, "session": false, "expirationDate": 1594469288, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "pl", "value": "n", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": true, "session": false, "expirationDate": 1539173288, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "spin", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": true, "session": false, "expirationDate": 1531581353, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "c_user", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": false, "session": false, "expirationDate": 1539307310, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "xs", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": true, "session": false, "expirationDate": 1539307310, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "fr", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": true, "session": false, "expirationDate": 1539307310, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "presence", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": false, "session": true, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "act", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": false, "session": true, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "x-src", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": false, "session": false, "expirationDate": 1531531321, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "pnl_data2", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": false, "session": false, "expirationDate": 1531531322, "storeId": "firefox-default", "firstPartyDomain": "" }, { "name": "wd", "value": "", "domain": ".facebook.com", "hostOnly": false, "path": "/", "secure": true, "httpOnly": false, "session": false, "expirationDate": 1532136132, "storeId": "firefox-default", "firstPartyDomain": "" } ] }

So yeah, here's a session for it :v (Yea I deleted the values)

Rob--W commented 6 years ago

"storeId": "firefox-default" means that the cookies are for non-private mode. Why did you expect the cookies to be added to your private browsing mode cookie store?

Do you just want the ability to copy (or move?) multiple cookies to a different browsing context? If so, then that would be possible once this feature request is implemented: #6

AnhDQHE181109 commented 6 years ago

Hmmm, ye... So I tried to export the cookies from github in the normal mode. And I signed out, then imported the cookies I exported them. STILL nothing :/

Rob--W commented 6 years ago

Did you sign out by clicking sign out, or by deleting cookies?

AnhDQHE181109 commented 6 years ago

Ehm... Clicking sign out?

Rob--W commented 6 years ago

A cookie serves as a way to identify the session. When you click "Sign out", then the server knows that the user does not want to continue the session any more, and it can stop accepting the cookie as an authentication method.

On the other hand, when you delete a cookie, the server does not know that the session of the cookie has ended (because it never received an explicit notification). In this case, the session can be resumed when you restore the cookie.

AnhDQHE181109 commented 6 years ago

So that's mean I have to delete the old cookies if they're exist?

Rob--W commented 6 years ago

Only if you want to end the session in the original browsing mode.

If you want the cookie to be useful elsewhere, then you should not use the "Sign out" functionality of the website, but just copy the cookies. If you want to move the session that is associated with the cookie (i.e. "sign out" in the original browsing mode), remove the cookies for that cookie store.

AnhDQHE181109 commented 6 years ago

Hmmm, so I tried to import the cookies again, then reload the cookie manager page, the cookies are applied :D So now, I'm thinking on how to stop github from replacing my cookies w/ its default one 🤔

Rob--W commented 6 years ago

then reload the cookie manager page

Tip: You don't need to reload the cookie manager, it suffices to click on the "Search" button again.

I'm thinking on how to stop github from replacing my cookies w/ its default one

Can you describe the exact steps that you took to test the scenario? If anything went wrong, then I can try to reproduce locally to see if there is a bug in my cookie manager.

AnhDQHE181109 commented 6 years ago
  1. I got into the cookie manager for that tab
  2. Then I selected all the cookies
  3. I got into the cookie exporter
  4. I exported it as text
  5. I signed out of github
  6. I got into the cookie manager for that tab again
  7. I got into the cookie importer
  8. Then I pasted the cookies, then clicked "Import" (Then it says, successfully imported x cookies)
  9. I went back to the cookie manager page then reload, cookies were successfully imported
  10. I switched back to the github tab, then reload it
  11. Then back to the cookie manager tab and the old ones were gone
Rob--W commented 6 years ago
  1. I signed out of github

If you used Github's "Sign out" button, then this step would have invalidated your cookies.

  1. Then back to the cookie manager tab and the old ones were gone

"old" as in the cookies that you imported? It is possible that Github has recognized that the cookies are unrecognized, and generated new cookies to start a new session.

If you want to test whether importing/exporting cookies are successful, replace step 5 with "Delete all cookies". And/or before importing the cookies, you can even open a new private browsing window, replace "firefox-default" with "firefox-private" with a text editor and then import again. Then you can see whether you have succeeded in migrating cookies.

AnhDQHE181109 commented 6 years ago

Oh well, that was weird... So I cleared the cache for github, then again I reimported the cookies. And, yea it worked flawlessly! :D Thanks for your support ;)

AnhDQHE181109 commented 6 years ago

I mean, I really appreciate that :v