Ajax controller for login - Problem session->set_userdata


#1

Hi.

I have created an ajax controller (on sessions module) 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 invoiceplane.

The AJAX controller code:

$this->load->library('session');
$this->load->model('sessions/mdl_sessions');

$session_data = array(
    'user_type' => '1',
    'user_id' => '1',
    'user_name' => 'Luca',
    'user_email' => 'lucatest@test.it',
    '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.

Regards,


#2

You can’t use file_get_contents or similar stuff to pass a session to a user.

Why using a controller to set static session data for a user? Makes no sense to me. Maybe you should explain what you want to do so we can help you with your idea… :thinking:


#3

Hi,

i must call the login controller to able the user’s login with another file php.
So i have a web form and with php i must enable login session into InvoicePlane.
So i have create this ajax controller.

How can i do this?


#4

I do not think that this is possible with the current codebase InvoicePlane offers. You would have to extend the app with both an API that handles external user logins and a session handler that allows external authentications based on methods that would need to be discussed about in regards of security.


#5

ok, but why with browser url invoke works and with curl no?

The session is created and saved on db but i think there is a problem with cookies.

There is a solution?


#6

Because using curl inside a PHP file will make your PHP file become the user, not the browser that opens the PHP file.

This is not a problem with cookies (which are not used anymore). It is not a problem at all because that’s how the architecture works.
InvoicePlane does not support what you want to do yet.


#7

There are other solutions or documentation? In next version of invoice plane there is this functionallity?


#8

No, InvoicePlane is not capable of your feature and will not ge the desired features in the next time. Sorry.


#9

hi, but codeigniter framework has this functionallity.

There is some libraries, plugins or helpers do do this?


#10

InvoicePlane was build with Codeigniter but is not the framework itself. Not possible at the moment. Period.