1
I have the following code:
$scope.loginUser = function (user) {
console.log(user);
$http.post("admin/php/login.php", user).then(function(response){
if(typeof(Storage) !== "undefined") {
localStorage.setItem("chave", "valor - algum conteudo aqui");
var valor = localStorage.getItem("chave");
console.log(valor);
} else {
console.log("Desculpe, mas o navegador nao possui suporte a Web Storage.");
}
$window.localStorage.setItem("idUsuarios",idUsuarios);
$window.localStorage.setItem("nome",nome);
$window.localStorage.setItem("email",email);
//console.log(response);
$location.path('admin/views/painel');
})
}
How should I set the data for those stored in localStorage
?
$window.localStorage.setItem("idUsuarios",?);
PHP:
<?php
$data = json_decode(file_get_contents("php://input"));
$email = $data->email;
$senha = $data->senha;
$sql = mysqli_query($con, "SELECT * FROM usuarios WHERE email='$email' AND senha='$senha' ");
$return = array();
while($row = mysqli_fetch_array($sql,MYSQLI_ASSOC)){
$return = $row;
}
echo json_encode($return);
Now that I went to see, the angular provides a localStorage ? what is its difference to the javascript default ?
– Gabriel Rodrigues