Answer the question
In order to leave comments, you need to log in
How to access session variables?
Hello everyone. There is a task in JS, which is connected in the footer of the page, to pass the login from _SESSION["login"]. JS is given by PHP script. If it is included in the page, then of course there is access to the array of sessions. And if you connect as JS, then of course not. Question!!! Is there another option besides how to write in cookies? Right now, I'm displaying it on the page like this, before connecting the JS file:
<?php
if(isset($_SESSION["login"])){
echo "<script>var myLogin = '".$_SESSION["login"]."';</script>\r\n";
}
else{
echo "<script>var myLogin = false;</script>\r\n";}
?>
<?php echo "<script src='".HOMEURL."core/js/js.php?nocache=".rand(11,99999999999)."'></script>"; ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question