Curl to prompt a User Name and Password

前端 未结 6 1997
臣服心动
臣服心动 2020-12-31 02:36

I have a password protect web folder on my site, I am fetching that folder on another domain using Curl, what I want is: when I try to open the URL it should as

6条回答
  •  天涯浪人
    2020-12-31 02:44

    you can use cookies there I think. The steps would be:

    1. If you try to curl "http://www.2nddomain.com/admin" with no cookies, it can return you a html login form.
    2. Your form's action would point to 2nd server and if the credentials were right, set the cookie there and return (redirect) to server 1.
    3. And if you curl again, you'd check the cookie on the other side and in this case, it could read that cookie and return you the admin page output instead.

提交回复
热议问题