How to use same request with curl

Hi

i have login via curl ,after successful login i couldnt get home page content via curl once successful login ,it again said to login. how to maintain session and cookie when calling a api via curl. can anyone give a solution .



$ckfile = tempnam ("/tmp", "CURLCOOKIE");
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
	curl_setopt($ch, CURLOPT_URL,$url);	
	curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);  // The name of a file to save all internal cookies to when the connection closes
	curl_setopt($ch, CURLOPT_HEADER,0); // TRUE to include the header in the output.	
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch,CURLOPT_AUTOREFERER,1);
	

	echo $result = curl_exec($ch); //execute curl and store data in result


Try Follow Location as 1, this might fix your problem

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // it will follow with server redirects

if i login via one browser it was working fine, if i login via some other brower means it take cookie previously stored in the text and logged with the same user. how to avoid.

how do to do like separate cookie for each browser. if we login one account via firefox in gmail ,we may login in gmail with another account in chorme or some other browsers. i want to do like that with curl . how to manage cookie and session when calling a url with curl