I have a series of pages that load a navbar from an external HTML file like so:
<head>
<script>
$(function() {
$("#navbar").load("navbar.html");
});
</script>
</head>
<body>
<div id="navbar"></div>
<!--other stuff here-->
This is all in a PHP page. However, there's part of that navbar that I want to set to set to a PHP $_SESSION variable (a username). Is there a way to easily do this?
Consider change navbar.html to navbar.php, then replace the username part by:
<?php echo($_SESSION["username"] ?>
then
$("#navbar").load("navbar.php");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With