I use JQuery Ajax to call sessions variables from PHP steamauth file, but it's not working, with this code (bellow), when I replace "$data['test'] = $_SESSION['steamid'];" to "$data['test'] = "ok";", it works very well, but with the initial code, no any alert window is poping and the div (ok), is still set to '...'.
I have no idea why I can't get the $_SESSION['steamid'] variable if it is set. Thank you very much
test.php:
<?php
header('Content-Type: application/json');
require ('steamauth/steamauth.php');
$data = array();
if(!isset($_SESSION['steamid'])) {
$data['retour'] = "ok";
$data['test'] = $_SESSION['steamid'];
echo json_encode($data);
} else {
include ('steamauth/userInfo.php');
$data['retour'] = "not ok";
echo json_encode($data);
}
?>
And main.html:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.get("test.php", function(data, status){
alert(data.retour);
document.getElementById('ok').innerHTML = data.test;
});
});
});
</script>
</head>
<body>
<button>clic</button>
<div id='ok'>...</div>
</body>
</html>
!isset(- so your saying if this field isn't set then try and use it.test.phpafter<?phpusesession_start();2. if!isset($_SESSION['steamid']condition is true then$_SESSION['steamid']is not available so how can you assign this to another variable?!shouldn't be there and is what is stopping it working. I'm voting to close this as a typo.