Estoy intentando mandar un par de variables obtenidas desde Firebase y quiero pasarlas a PHP. Aquí las estoy mandando por GET, pero me gustaría mandarla por POST o por algún método el cual no sea a través de una URL.
firebase.initializeApp(firebaseConfig);
var provider = new firebase.auth.GoogleAuthProvider();
function IngresoGoogle(){
firebase.auth().signInWithPopup(provider).then(function(result) {
var token = result.credential.accessToken;
var user = result.user;
var name = result.user.displayName;
var correo = result.user.email;
var foto = result.user.photoURL;
location.href = '../login/index.php?name=' + name + '&correo=' + correo + '&foto=' + foto;
}).catch(function(error) {
var errorCode = error.code;
if (errorCode === 'auth/account-exist-with-diferent-credential') {
alert('El usuario ya existe');
}
});
}
document.getElementById('btn-Google').addEventListener('click',IngresoGoogle,false);
Recibo la variable en PHP de esta forma
include '../conexion/conexion.php';
$username= htmlentities($_GET['name']);
$userphoto = htmlentities($_GET['photo']);
$usercorreo = htmlentities($_GET['correo']);
$_SESSION['name'] = $username;
$_SESSION['photo'] = $userphoto;
$_SESSION['correo'] = $usercorreo;
Me gustaría saber es una buena practica realizarlo de esa manera, estuve investigando y según creo el htmlentities evita que se modifique la varible mediante URL, es correcto? Desde ya muchas gracias.