# Create a session and retrieve data from the server

**URL:** <https://forum.ionicframework.com/t/create-a-session-and-retrieve-data-from-the-server/116940>\
**Category:** ionic-v3\
**Created:** [January 1, 2018, 8:43pm UTC](https://forum.ionicframework.com/t/create-a-session-and-retrieve-data-from-the-server/116940 "2018-01-01T20:43:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SmeRT59](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@SmeRT59](https://forum.ionicframework.com/u/SmeRT59)\
**Post date:** [January 1, 2018, 8:43pm UTC](https://forum.ionicframework.com/t/create-a-session-and-retrieve-data-from-the-server/116940/1 "2018-01-01T20:43:10Z")

</div>

With the help of the http.post I send the data to the server where they are processed.  
The code on the server:

```auto
      case "loginUser":

        $loginUsername = filter_var($_REQUEST['username'], FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
		$loginPassword = filter_var($_REQUEST['password'], FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW);
	  
		$DB_SERVER = "
		$DB_USER = ";
		$DB_PASS = "
		$DB_NAME = "
	
		$con = mysqli_connect("$DB_SERVER","$DB_USER", "$DB_PASS", "$DB_NAME") or die ("cannot connect server ");
		
		echo nl2br("\n Подключение к базе прошло успешно!");
		echo json_encode($loginUsername);
		
		$query =mysqli_query($con, "SELECT * FROM Users WHERE username = '".$loginUsername."'");
		$numrows=mysqli_num_rows($query);
		
		if($numrows!=0){
				
			while($row=mysqli_fetch_assoc($query)){
					
				$dbusername=$row['username'];
				$dbpassword=$row['password'];
				echo nl2br("\n Пользователь ". $dbusername ." найден! Сейчас производим сравнение паролей...");	
			}
			
			if($loginUsername == $dbusername && $loginPassword == $dbpassword) {
				
				$_SESSION['session_username']=$loginUsername;
				echo nl2br("\n Вход успешно выполнен!");
	
			} else {
				echo nl2br("\n Ошибка: Пароль неверен!");
				$json = '{"Status": "False"}';				
			}
  
   } else {
	   echo json_encode(array('Message:' => 'User not found...'));
   }
   break;

```

With the help of the ntp.post I send the data to the server where they are processed. How do I get back to the meaning after running the script in the PHP on the server? They say that this is done with the help of JSON, but I do not know him. tell me how to implement it.  
Unfortunately, at the moment, I can not attach the code on the mobile application.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:57pm UTC](https://forum.ionicframework.com/t/create-a-session-and-retrieve-data-from-the-server/116940/2 "2021-07-19T21:57:16Z")

</div>

Closed on July 19, 2021, 9:57pm UTC


