0
Good night,
I’m creating an app on ionic and angularjs did the login through an ajax request to php which in turn checks and validates all through the database, the only problem I’m having and how after the login is successfully used session that I create in php.
PHP
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Content-type: application/json");
session_start();
require_once("../funcoes/funcoes.php");
$sql = $conexao->prepare("SELECT * FROM users_social WHERE fb_email = :user AND password = :pass ");
$sql->bindParam(':user', $_GET['email'], PDO::PARAM_STR);
$sql->bindParam(':pass', sha1($_GET['password']), PDO::PARAM_STR);
$sql->execute();
if($sql->rowCount() == 1){
$row = $sql->fetch(PDO::FETCH_ASSOC);
$_SESSION = array();
$_SESSION['user_id'] = $row['id'];
$_SESSION['nome'] = $row['fb_nome'];
$_SESSION['user_foto'] = $row['user_foto'];
$_SESSION['user_slug'] = $row['slug'];
}else{
echo "erro ";
}
?>
Controller
.controller('LoginInterno', function($scope, $http) {
$scope.Btnlogin= function (input){
$http.post("https://www.sabeonde.pt/api/api_login.php?email=" + input.email + "&password=" + input.password).success(function (data) {
window.location = "#/app/home"
$scope.login = data;
}).
error(function (data) {
alert("Dados Incorrectos");
});
};
})
Of course there are several ways to do this, but the question is, is this way quite safe? (is a good practice of programming for Angularjs?)
– Milrak Pereira Pessoa