Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I copy cookies from Chrome?

I am using bash to to POST to a website that requires that I be logged in first. So I need to send the request with login cookie. So I tried logging in and keeping the cookies, but it doesn't work because the site uses javascript to hash the password in a really weird fashion, so instead I'm going to just take my login cookies for the site from Chrome. How do get the cookies from Chrome and format them for Curl?

I'm trying to do this:

curl --request POST -d "a=X&b=Y" -b "what goes here?" "site.com/a.php" 
like image 651
jackcogdill Avatar asked Feb 20 '14 20:02

jackcogdill


People also ask

Can you transfer cookies from one computer to another?

To hand over cookies from one browser to another you most likely will have to copy-paste cookie's properties. This works if you have just a handful of cookies, but it requires manually copy-and-past for each one.

How do I extract cookies from a website?

For Google Chrome go to View > Developer > Developer Tools or CMD + ALT + I on Mac or F12 on Windows. ‍Now open the Application tab and check the cookies for each domain. Usually the cookies have names that resemble the name of the service they are being used by.

Can cookies be copied?

Yes it is possible. how hard it would be? Depends on what mechanism is used by Gmail to identify if it is the same browser.


Video Answer


2 Answers

  1. Hit F12 to open the developer console (Mac: Cmd+Opt+J)
  2. Look at the Network tab.
  3. Do whatever you need to on the web site to trigger the action you're interested in
  4. Right click the relevant request, and select "Copy as cURL"

This will give you the curl command for the action you triggered, fully populated with cookies and all. You can of course also copy the flags as a basis for new curl commands.

like image 195
that other guy Avatar answered Nov 04 '22 13:11

that other guy


In Chrome:

  • Open web developer tools (view -> developer -> developer tools)
  • Open the Application tab (on older versions, Resources)
  • Open the Cookies tree
  • Find the cookie you are interested in.

In the terminal

  • add --cookie "cookiename=cookievalue" to your curl request.
like image 25
user2537361 Avatar answered Nov 04 '22 14:11

user2537361