session lost on redirect using cURL

Get help with any scripts or php pages.

session lost on redirect using cURL

Postby hrsms » Sun Aug 03, 2008 5:45 pm

I have a function "Redirect", as shown below (comments and error-checking removed for brevity):

From the little research I've done, I thought that setting the CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE options as I have done would make the current session cookie available in the redirected page. But it is not, and nothing appears to be written to curl_cookies.txt. The file has permissions 666 so that it can be read and written to. It is under the home directory so it cannot be browsed to. Did I not specify the path correctly?

Can anyone help?

Code: Select all
function Redirect($url, $postinfo)
{
    $curlh = curl_init();
    curl_setopt($curlh, CURLOPT_URL, $url);

    if(isset($postinfo))
    {
        curl_setopt($curlh, CURLOPT_POST, 1);
        curl_setopt($curlh, CURLOPT_POSTFIELDS, $postinfo);
    }       

    curl_setopt($curlh, CURLOPT_COOKIEJAR, "/curl_cookies/curl_cookies.txt");

     curl_setopt($curlh, CURLOPT_COOKIEFILE, "/curl_cookies/curl_cookies.txt");
       
    curl_exec($curlh);
    curl_close($curlh);
 
    return 1;
}
hrsms
Webmaster status
 
Posts: 17
Joined: Thu Feb 15, 2007 8:03 pm

session lost on redirect using cURL

Postby shashant » Sun Aug 03, 2008 10:15 pm

Hello,

I suggest you to contact your website developer to have correct code for function "Redirect" . They can assist you better in this regard.
shashant
Site Admin
 
Posts: 23
Joined: Wed Jan 16, 2008 7:47 am

Postby hrsms » Mon Aug 04, 2008 8:12 am

I am the website developer.
I'm looking for help with php code I have written.
Is this the wrong forum?
hrsms
Webmaster status
 
Posts: 17
Joined: Thu Feb 15, 2007 8:03 pm


Return to PHP and Script Support (new)

Who is online

Users browsing this forum: No registered users and 1 guest

cron