Hello, I was fetching a data from membership area(using username and pw of course). I used a session ID that I got with Firebug but when it changes my script stops working. I need this sessionID to load up site contents and download a few files from server. However, I am stuck, because I don't know how to extract it. My code is : $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "loginpage.php"); // login curl_setopt($ch, CURLOPT_POSTFIELDS, "D=$D"); // variable with username and pw curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $reply2 = curl_exec($ch); curl_close($ch); PHP: What am I doing wrong? The cookie is not saved anywhere I guess and I cannot use it later to load up things I really want to get...
Just asking, don't you need to use full http://domain urls ? <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.domain.com/loginpage.php"); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=something&password=something"); curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $login = curl_exec ($ch); curl_setopt($ch, CURLOPT_URL, "http://www.domain.com/membership_area.php"); $members = curl_exec ($ch); curl_close ($ch); ?> PHP: $members, contains the HTML output of the membership_area.php page.
Hi, I just change URLs so that no one would see actual site. Thanks for help. This works, but, again, it sends a variable from LOGIN.php to script/server.php containing information on WHAT to load, and sends sessionID to it. However, I have no idea how to extract it... Here is the cookie it POSTS to server.php dp_C_dp_sid=0282d4809401ef4454e75aebd87f366c; RPC_dp_sid=0282d4809401ef4454e75aebd87f366c; dp_C_auth=9bc6b4fabc32b0ec8aa0663cbc5d2b6f; gpf_language=en-US PHP: I need to get either dp_C_dp_sid or RPC_dp_sid. This post request generates after I press login button and browser proceeds to member area.
Is it a actual session or cookie? If there is a option to stay logged in, do it with your browser if using Firecookie goto the cookie tab an export cookies from this site to a file. You could then use something like this. $cookie = "/home/xxxxx/cookie.txt"; $url = "www.example.com/member.php"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $html = curl_exec ($ch); curl_close ($ch); PHP: I mean if its a session you can export it using FireCookie/FireBug and modify it to never expire and keep logging in so long as you don't log into the actual account again.