CodeIgniter Forums
Session login problems with PHP file_get_contents and CURL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Session login problems with PHP file_get_contents and CURL (/thread-68806.html)



Session login problems with PHP file_get_contents and CURL - luca - 08-28-2017

Hi,

I have created an ajax controller with static data to set the login session for a user. If i go to this controller with browser (link: http: // localhost: 8888 / index.php / sessions / ajax / setsession) works and the session works correctly: the user is logged on my soft.


The AJAX controller code:



PHP Code:
$this->load->library('session');

$session_data = array(
 
   'user_type' => '1',
 
   'user_id' => '1',
 
   'user_name' => 'Luca',
 
   'user_email' => '[email protected]',
 
   'user_company' => ''
);
$this->session->set_userdata($session_data); 


If i try to do this with php (file_get_contents) or php (curl), the system does not work, the sessions are not created and the user is not logged.

I have read the session library and i think there is a block on your code or similar stuff.

Is this the problem? What is the solution?

Please help me to solve.


RE: Session login problems with PHP file_get_contents and CURL - sasbass - 08-29-2017

Firstly you need to know what is the AJAX.
After that you can push login data to your link: http: // localhost: 8888 / index.php / sessions / ajax / setsession
After that can try print_r($this->session->userdata); there you can see your session info.