1. #1
    Ext User
    Join Date
    Jun 2008
    Posts
    6
    Vote Rating
    0
    EuMendoza is on a distinguished road

      0  

    Default How can I get the value $_SESSION["id"]

    How can I get the value $_SESSION["id"]


    I need to use the value $_SESSION["id"] that is in the file "pepe.php", in the "var number" that is in "pepe.js". Sorry, I have a bad english level. Thanks.

  2. #2
    Sencha User
    Join Date
    Jun 2008
    Posts
    69
    Vote Rating
    0
    pouniok is on a distinguished road

      0  

    Default


    Hi,

    You can do like this :

    write this in pepe.php before including pepe.js :

    Code:
    <script type="text/javascript">
        var number = <?php echo $_SESSION["id"]; ?>; // add quotes if the id isn't a real number
    </script>
    <script type="text/javascript" src="pepe.js"></script>
    So you can access number as a global variable in pepe.js


    Or rename pepe.js in whatever.php, include it with <?php include() ?> in pepe.php.
    Then you could call php code with in your JS.

  3. #3
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    1
    devnull is an unknown quantity at this point

      0  

    Default


    or you could make an ajax call back to a php page that would return that value.
    I really hate the idea of code that generates more code (php generating javascript)...

Thread Participants: 2