Welcome Guest, Not a member yet? Register   Sign In
How to access server-side features?
#1

I have extensively searched for a solution but have been unsuccessful in finding one.

In Angular 1.x, I used to include JavaScript files in PHP pages and load those pages from the server-side code, such as a CodeIgniter controller.

However, in Angular 2.x, I am unable to determine how to utilize server-side features like $_SESSION. For example, I want to insert data into a MySQL table and send the data using the POST service of Angular 2. How can I achieve this while knowing which user is logged in and has created that record?

Here is the code snippet I am working with:


$city = $this->input->post("city");
$specialty= $this->input->post("specialty");

$data = array("city" => $city, "specialty" => $specialty, "createdBy" => $this->session->userdata("userid"));

$this->db->insert("citywise", $data);
My concern is how to obtain the $this->session->userdata("userid") value since the application is loaded on the client-side, and everything is handled through REST services. Although I can retrieve login data on the client's browser using localStorage, I am uncertain about how to handle the server-side aspect.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB