Save cookies between two curl requests

后端 未结 3 1931
春和景丽
春和景丽 2020-12-02 16:11

I know that using cURL I can see my received cookies / headers by using

curl --head www.google.com

And I know that I can add h

3条回答
  •  时光取名叫无心
    2020-12-02 17:05

    I would like to thank everyone here for helping me find a solution to login to my wordpress site using CURL. This is my little contribution, hope that it will also help some one who stumble across this in the future

    For windows 10 build newer than 1706 you can use curl from the command line.

    curl -c c:\Users\\Desktop\cookie.txt -F "log=" -F "pwd=" https://acme.net/wp-login.php
    

    you won't see any response in your terminal. it just refreshes itself but your cookie is already stored.

    then type in the below to read and send the cookies you just stored.

    curl -b c:\Users\\Desktop\cookie.txt -L https://acme.net/my-profile/
    

    the entire webpage that should only be accessible for logged in users will be rendered inside your terminal including any data that is loaded dynamically via javascript.

    Even if the end point of your WP login url is '/register/log-in' or '/login' i still recommend you use '/wp-login.php' as the endpoint. That's because some WP themes have a login nonce in a hidden input on their login page. The native WP login page does not have this.

    other sources you can refer to:

    https://wpmayor.com/login-to-wordpress-dashboard-via-curl/

    https://gist.github.com/subfuzion/08c5d85437d5d4f00e58

    https://www.youtube.com/watch?v=B4ilccLUQVs

    https://makandracards.com/makandra/48262-how-to-use-cookies-with-curl

提交回复
热议问题