Good evening,
I am creating an app in ionic
and angularjs
I made login
through an ajax request to php
which in turn verifies and validates everything through the database, the only problem I am have and how after login is done successfully use the session
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");
});
};
})