Login with session

Hello everyone can i ask some help how can i implement a session with this code of login and to destroy session when logout.
login.html

Username Password

controller.js
.controller(‘LoginCtrl’, function($scope, $state, LoginService) {
$scope.form = {};

$scope.login = function(){

if((angular.isDefined($scope.form.username)
  && $scope.form.username !== "")
  && angular.isDefined($scope.form.password)
  && $scope.form.password !== ""){

  LoginService.login($scope.form).then(function(response){
     
      if(Storage)
      {
      localStorage.setItem('loginDetails', JSON.stringify(response.data.username));
        $state.go('classattendance');
    } else {
      alert('String is not defined in this browser. please use other storage.');
    }
  }, function(error){

  });
} else {
}

}
})
.controller(‘ClassCtrl’, function ($state, $scope, $http) {
if (localStorage[‘loginDetails’] == ‘undefined’)
{
alert(“Invalid access”);
$state.go(‘login’);
}
})

service.js
.service(‘LoginService’, function($http){

var vm = this;
var url = ‘http://127.0.0.1/mobile/’;

vm.login = function(loginData){

return $http.post(url + 'login_service.php',loginData);

}
})

login_service.php

<?php header("Access-Control-Allow-Origin: *"); require_once('connection.php'); $post_data = file_get_contents('php://input'); $request = json_decode($post_data); $user = $request->username; $pass = $request->password; $select_sql ="SELECT * FROM users WHERE username = '" . $user . "' AND passwrd = password('" . $pass . "')"; $result = $con->query($select_sql); $re=$result->fetch_assoc(); echo json_encode($re); ?>