2017-12-04 6 views
1

RSA 토큰으로 보호되는 회사의 인트라넷에 로그온하려고합니다. 로그에 필요한 모든 데이터를 찾을 수 있었고이 코드를 사용하여 작동합니다.PHP 및 cURL을 사용하여 원격 보호 사이트에 로그온

<?php 
//init curl 
$ch = curl_init(); 

//Set the URL to work with 
curl_setopt($ch, CURLOPT_URL, $loginUrl); 

curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5"); 

// ENABLE HTTP POST 
curl_setopt($ch, CURLOPT_POST, 1); 

//Set the post parameters 
curl_setopt($ch, CURLOPT_POSTFIELDS, $var); 

//Handle cookies for the login 
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 

//Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL 
//not to print out the results of its query. 
//Instead, it will return the results as a string return value 
//from curl_exec() instead of the usual true/false. 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

//execute the request (the login) 
$store = curl_exec($ch); 

?> 

로그온 후 즉시 로그 아웃됩니다. 세션 당 최대 2 시간이 설정됩니다. 어떻게 ist가 정상적으로 설정 되었습니까? 원래 사이트 코드에서이 정보를 어디에서 찾을 수 있습니까? 쿠키에 저장 될 것 같습니까? LogIn 직후에 로그 아웃되지 않도록하려면 어떻게해야합니까?

안부, 마이클

+0

안녕하세요, @mentle, 정렬하면 알 수 있습니다. 작성한 수정 사항을 여기에 게시하십시오. –

답변

0

나는 세션과 쿠키 정보의 가용성에 그것으로 인해 믿습니다. 로그인 성공과 함께 코드를 요청하면 로그인으로 생성 된 쿠키 값을 확인하고 세션 값을 확인합니다.

그래서 일치하지 않으면 로그 아웃됩니다.

이 코드는 사용자의 목적에 부합한다고 생각하지 않습니다.