Jump to content

A question about curl and "CURLOPT_FOLLOWLOCATION"


cunoodle2

Recommended Posts

Ok.. so I have a curl script that auto logs me into my account at chase.com (I use it for tracking my IRA on a daily basis). They recently modified the login process and my script no longer works. Here is the only way to make it work...

Steps 1 and 2 of my code work PERFECT so far

1. Submit the form values to 'formpost.fcc'
I have NO idea what the source does for that page (something with a session and it just redirects me to..

2. sso_logon.jsp?fromLoc=ALL&LOB=COLLogon At this point I am still good.




Here is where my code stops working.
3. On the page mentioned about it has ANOTHER redirect to '/online/logon/on_successful_logon.jsp?LOB=COLLogon'

BUT it is redirecting the page to www.MY URL HERE.com/online/logon/on_successful_logon.jsp?LOB=COLLogon where I want it to redirect to www.chase.com/online/logon/on_successful_logon.jsp?LOB=COLLogon

Any ideas? I can provide the code in here upon request.
Link to comment
Share on other sites

Do you have at least these two options specified?

curl_setopt($c, CURLOPT_MAXREDIRS, 2);
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);

[a href=\"http://us2.php.net/manual/en/function.curl-setopt.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.curl-setopt.php[/a]

Link to comment
Share on other sites

toplay I am glad you hopped on here. I often have these "out of the norm" problems and you seem to be one of the few that has the answers. Unfortunatley this still does not work. Here is the code I am using now...

######### Prepare curl settings and variables #########
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "https://chaseonline.chase.com/siteminderagent/forms/formpost.fcc");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);

I actually noted that the code that is causing this problem is this which I can see on the 'view source' of the page...

function init()
{
processCookieOnSuccess();

<!-- document.on_succes_logon.action = "https://pfsonline.chase.com/pfsonline/logon/sso_pfs_logon_welcome.jsp";-->

<!-- document.on_succes_logon.action = "sso_logoff_question.jsp";-->

document.on_succes_logon.action = '/colappmgr/colportal/customer?_nfpb=true&_pageLabel=page_myaccounts';
window.location.href='/colappmgr/colportal/customer?_nfpb=true&_pageLabel=page_myaccounts';
//document.on_succes_logon.submit();

//document.on_succes_logon.submit();
//document.location.href = document.on_succes_logon.action;
return true;
}
Link to comment
Share on other sites

You're missing this:

curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');

The cookie jar is good for the first request which sets the name of the file to store the cookie in. But on subsequent requests, you have to use the cookie file option and point it to the same cookie file so cURL reads the cookies from the file and sends them along with the HTTP request.

Specify both the cookie jar and cookie file at first since you have redirects. But if that doesn't work, then you may have to do it in steps. Like not follow redirects initially.

In case you're running this on a web host and not your local server, remember to save the cookie.txt in a private area (and not accessible to the public like the web folder).

While testing at first, it's probably good to increase CURLOPT_MAXREDIRS to more than 2 for now.

At the end, remember to delete (unlink) the cookie file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.