Grab current session's cookie with cURL
Curl can handle that for you; there is an option to store the cookies in a cookiejar and use those in subsequent requests.
Here is an example from the main curl site, which uses cookies from a file cookies.txt to set some and at the same time stores new cookies in newcookies.txt.
http://curl.haxx.se/docs/httpscripting.html#Cookie_Basics
curl --cookie cookies.txt --cookie-jar newcookies.txt http://www.example.com
When going through a login process, for example, one would reuse the cookies from cookie jar.
Nhoya
Updated on June 04, 2022Comments
-
Nhoya almost 2 years
I'm working on a script that send a POST request to an URL, actually I'm sending the cookies manually in the header.. but how to take it from the current browser session?
I used tcpdump and grep but it's really the wrong choice :,D Some suggestions?
I wont take them from a file but from the browser session and without enter in the cookie path of the browser
-
Tom Fenech over 9 yearsIt would be useful to provide an example showing what you mean here, in case the link changes in future.
-
Nhoya over 9 yearsOk but this is the same to take from an input... I want to take the cookies from the browser session without go inside the cookie path
-
nlu over 9 yearsSo you were talking about your browser session all the time?
-
Nhoya over 9 yearsYes, i was sure i wrote it.. Sorry
-
nlu over 9 yearsSorry, I overlooked that: just export the cookies and use them with curl: askubuntu.com/questions/161778/…