A
A
Alexey Yarkov2014-12-22 10:55:48
PHP
Alexey Yarkov, 2014-12-22 10:55:48

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>"; ?>

I would somehow get to the array with sessions from the js.php file

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2014-12-22
@yarkov

session_start()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question