[Pro] PHP, cURL and Cookies

Walter,

I still get a blank page even after adding the error reporting code to my PHP script as follows:

<?php
    $curl = curl_init();
    curl_setopt ($curl, CURLOPT_URL, "http://hartford.macusa.net/fmi/iwp/cgi?-db=Install_Info.fp7&-startsession");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    ini_set('display_errors', true);
	error_reporting(E_ALL);
    $result = curl_exec ($curl);
    curl_close ($curl);
    print $result; 
?>

But when I substitute example.com for the above hartford.macusa.net URL, the page content displays fine. But example.com doesn’t use sessions or cookies. So I guess that shows the MacUSA page is blank due to non-existent handling of the cookie it assigns.


I couldn’t find a FireFox extension named “Tamper Session” but I installed one called “Tamper Data”. Even so, that extension doesn’t really do much that I can see. When I open its window and then load the MacUSA Login page, here’s a screenshot of what I see:

http://cl.ly/image/200a1P3R252v/Image%202015-07-09%20at%203.49.33%20PM.png

No mention of a Cookie in sight. So I guess you remembered the name of the FF extension wrong.


I do have FireBug in FireFox. It works pretty much like the Console in Safari though. If I open the MacUSA Login page in Safari with the Console open to show Cookies, this is what I see:

http://cl.ly/image/291u0Q2A2x0y/Image%202015-07-09%20at%204.17.56%20PM.png

As you can see in that screenshot the cookie seems to be named “fmi-cookie”. But the strange thing is, when I review the JavaScript on that MacUSA Login page, it seems to say the cookie name is “check”:

<script type="text/javascript" language="JavaScript1.4">
<!--
	function setCookie(cookieName,value)
	{
			var today=new Date();
			today.setDate(today.getDate()+ 1);
			document.cookie=cookieName+ "=" +escape(value)+ ";expires="+today;
	}

	function getCookie(name)
	{
		var start = document.cookie.indexOf( name + "=" );
		if (start == -1) return null;
		var nameLength = start + name.length + 1;
		var end = document.cookie.indexOf( ';', nameLength );
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring( nameLength, end ));
	}

	function checkCookie(){
		setCookie('check','check');
		testCookie = getCookie('check');
		
		if(testCookie == null){
			return false;
		}else{
			document.cookie = 'check' + '=' +';expires=Thu, 01-Jan-1970 00:00:01 GMT';
			return true;
		}
	}
			
	function getSid()
	{
		var url = window.top.location.href;
		var result = "";
		if ( url != null )
		{
			var sid = null;
			var index = null;
			if(checkCookie() == true){
				index = url.indexOf( "JSESSIONID=" );
			}else{
				index = url.indexOf( ";jsessionid=" );
			}
			if ( index != -1 )
			{
				var end = url.indexOf ( "&", index );
				if ( end != -1 )
				{
					result = url.substring ( index, end );
				}
				else
				{
					result = url.substr ( index );
				}
			}
		}
		return result;
	}

	var sid = getSid();
	if ( sid.length > 0 ){
		document.write ( '<script type="text/javascript" language="JavaScript1.4" src="/fmi/iwp/cgi' + sid+ '?-authinfo' + '"><' + '/script>' );
	}else{
		document.write ( '<script type="text/javascript" language="JavaScript1.4" src="/fmi/iwp/cgi?-authinfo' + '"><' + '/script>' );
	}
		

-->
</script>

So I am rather confused at how to proceed at this stage.

–James W.

(Saving the entire text of this post prior to clicking SEND this time! Ack!)


dynamo mailing list
email@hidden
Update your subscriptions at: