获取链接后的PHP / cUrl重定向

I have this code and need to help for transfer

$curl = new curl();
$curl->cookies('cookies/'.md5($_SERVER['REMOTE_ADDR']).'.txt');
$curl->ssl(0, 2);

$url = "https://exapmle.com/login/";

But when script take exaple.com/login has redirected to login.exapmle.com/logon?=Data+Data how can i make after redirected $url to use new redirected url.

Please help me anyone

I honestly don't know the curl class, but if it works simillarly to the curl_* functions, you could do the following:

$curl->setOpt(CURLOPT_FOLLOWLOCATION, true);

Hope it was helpful.