Results 1 to 3 of 3

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

  1. #1
    Ext User
    Join Date
    Jun 2008
    Posts
    6
    Vote Rating
    0
      0  

    Default 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
    74
    Vote Rating
    1
      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
    3
      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)...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •