Solved:
Yay. In addition to what you wrote Drew, I found this: http://www.smooka.com/blog/2009/07/24/maintaining-php-session-when-using-curl/
session_write_close(); before initializing the next set. Now I just need to figure out AJAX/jquery, because it looks like I can’t register resource variables (e.g. Curl’s handle) in a session.
I want to login to a site using cURL. Their login process uses a token which I am able to parse using file_get_contents(). However, when I try to access the site again using cURL, the token is no longer good. Is there a way read the file using cURL, pause to do the calculations/steps, and then post the fields? Is there a better way?
The token is probably no longer good because it is associated with a session cookie that gets set when you access the site. Since
file_get_contentshas no cookie tracking, you should use cURL to request the initial URL, grab the token, do your calculations, and then post back using cURL again.To get cURL to keep track of the cookies, use the
CURLOPT_COOKIEFILEandCURLOPT_COOKIEJARoptions for the cURL handle.Here are some other answers of mine that use cURL to login to various websites and perform actions; looking at the code may be of help to you.