Okay, so my code to validate the user and log them into their account. My code for user validation is a separate file with no HTML, just PHP. It then echo either true or false to my homepage, which if true, will redirect them to the main page while a user logged in. My login file is as follows:
while ($row = mysql_fetch_array($res)){
if ($row['password'] == $pass){
echo "true";
session_start();
$_SESSION["username"] = $user;
} else {
echo "false";
}
}
If the code echos true, the javascript code will redirect them using window.location. On the page they get too, home.php, the PHP code (not html) looks like this:
<?php session_start(); ?>
<script>
var ses = "<?php echo $_SESSION["username"]; ?>";
console.log(ses);
</script>
For some reason, it logs nothing. It still logs, but it logs a blank variable. If anyone could help, that would be amazing! Thank you.