I make a POST authorization request using CURL . On OpenServer 'e (LAN), authorization works fine, and when I upload files to the hosting, it is not authorized from the hosting. The server responds with a redirect to the main one. The cookie.txt has 777 permissions and the cookie is written to it when you try to log in. I cannot understand what is happening, maybe you can help me figure it out. Maybe some settings on the hosting need to do? I have a VPS - Operating System: linux / rhel ( CentOS 7.2 x64 cPanel11 5 )

 function authSite($data){ $fp = fopen("cookie.txt","w"); fclose($fp); $login = curl_init(); curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($login, CURLOPT_TIMEOUT, 36); curl_setopt($login, CURLOPT_REFERER, "http://SITE.RU/index.php"); curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($login, CURLOPT_URL, "http://SITE.RU/index.php"); curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36"); curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($login, CURLOPT_POST, TRUE); curl_setopt($login, CURLOPT_POSTFIELDS, $data); $result = curl_exec ($login); if (curl_errno($login)) { return curl_error($login); } else { return $result; } curl_close ($login); unset($login); } $dataPost = "login=LOGIN&password=PASSWORD&submit=sing in"; $res = authSite($dataPost); print_r($res); 

Produces the following code:

 <META HTTP-EQUIV="REFRESH" CONTENT="2;URL=index.php">redirectArray ( [0] => ) 
  • Add var_dump($result); immediately after calling cur and see what displays - rjhdby
  • phpinfo (); and see if the server’s curl module is worth - Ricco381
  • @rjhdby after using var_dump($result); I realized that the authorization still happens, there is such an authorization on the site - after authorization a blank page is displayed with redirect to the main page, apparently the problem is that the CURL request does not follow all the redirects or something is wrong with the cookie. Can you advise what other options you need to add? - Cinema Trailers

0