简体   繁体   中英

Php Curl Login Trouble

I'm really amateur to php curl. I would like to know how to login to a site with form like:

<form method="post" action="/log.php">
  <input type="hidden" name="sessionid" value="a49e4ebb5b71d0745573d37331bfc2cb2880" />Username: 
  <input type="text" name="user" />Password: 
  <input type="password" name="pass" />
  <input type="submit" name="submit" value="Log in" />
</form>

Here you can see a fieldname called "sessionid". It just keeps on changing in every reload. So when i try to login with the curl, it says 'Invalid Session'. So can anyone please help me?

This behaviour is absolutely normal.

Your autologin process can be explained this way :

在此处输入图片说明

Your problem is at the step 4 : you cannot set a cookie for another domain.

  • Your website www.autologin.com has the domain autologin.com

  • The target website www.protected-site.com has the domain protected-site.com

If you try to set a cookie from www.autologin.com to the domain protected-site.com, your browser will ignore it.

Your cURL script should perform his own Login with user and password. There are several Methods (Basic, NTLM, ...) supported by cURL. Further, cURL can handle its own cookies using a cookie jar.

But once i found a blog where it's admin made a facebook status updater script with curl and i missed it. Facebook is having session ids right? But how did he managed to do that?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM