Welcome Guest, Not a member yet? Register   Sign In
Trouble with cURL and Sessions
#1

[eluser]Unknown[/eluser]
I have been stuck on this issue for months. Please help. How do you maintain a session? I turned on database sessions and everytime I run a cURL to a page it loses the sessions and starts a new one. I am using 1.7.0. I tried passing the cookie to it. Because it regenerates, I also lose the user information in the cURL retrieval.

Ahh!
#2

[eluser]Unknown[/eluser]
Ajax does not exhibit this issue. I have been able to cut down the session regeneration from infinite to 2.

Example code for views/sandbox/dispatcher:
Code:
<div id="sandbox_dispatcher">
    <div class="content">
        <div class="header">
            <h1>Sandbox > Dispatcher</h1>
            
            <p>Attempting to port over a dispatcher from CakePHP that does not interrupt sessions.</p>
        </div>
        
        <div class="content">
            <div id="dispatcher_test">
                <h3>Dispatcher Test</h3>
                
                &lt;?
                    $headers = array();
                    foreach(getallheaders() as $key=>$value) {
                        $headers[] = $key.': '.$value;
                    }
                ?&gt;
                
                <div id="dispatch_curl">
                    <h5>Dispatch to another controller using cURL</h5>
                    
                    &lt;?
                        // This doesnt work because it keeps affecting the session table
                        $curl = curl_init(base_url().'sandbox/dispatcher_target/');
                        curl_setopt_array($curl, array(
                            CURLOPT_HTTPHEADER => $headers,
                            CURLOPT_HEADER => 0,
                            CURLOPT_USERAGENT => $this->session->userdata['user_agent']
                        ));
                        curl_exec($curl);
                    ?&gt;
                </div>
                
                <div id="dispatch_ajax">
                    <h5>Dispatch to another controller using AJAX</h5>
                    
                    <div class="ajax_resp">                        
                    </div>
                </div>
            </div>
            
            <div id="current_sessions">
                <h3>Current Sessions</h3>
                
                &lt;? pr($sessions) ?&gt;
                
                <ul>
                </ul>
            </div>
        </div>
    </div>
</div>

[removed]
window.addEvent('domready', function() {
    new Request({url: leafm.globals.BASE_URL + 'sandbox/dispatcher_target'})
        .addEvent('complete', function(resp) {
            $('dispatch_ajax').getElement('div.ajax_resp').set('html', resp);
        })
        .send();
});
[removed]




Theme © iAndrew 2016 - Forum software by © MyBB