#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Posts
    92
    Rep Power
    14

    how to pass session id in javascript?


    how to pass session id in javascript...

    i've tried this, but it's not correct..

    PHP Code:
    location.href = "http://www.abc.com/cart.php?uid="+ <? echo $uid ?>"&sid="+ <? echo $SID ?>;
    how to pass?? pls advice!!
  2. #2
  3. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Jun 2002
    Location
    Washington, DC
    Posts
    2,692
    Rep Power
    22
    Try ->

    PHP Code:
    echo SID
    You have $SID - SID is a predefined constant so drop the '$'... - also drop the 'sid=' as it will also echo the session_name.

    See if that works for you...
    ~ Joe Penn
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Posts
    92
    Rep Power
    14
    i tried this...not working:
    PHP Code:
    location.href = "localhost/kbj/shop_cart/user_cart.php?uid="+ <? echo $uid ?>"&"+ <? echo SID ?>;
    and also tried this, also cannot..
    PHP Code:
    location.href = "localhost/kbj/shop_cart/user_cart.php?uid="+ <? echo $uid ?><? echo SID ?>;
  6. #4
  7. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Jun 2002
    Location
    Washington, DC
    Posts
    2,692
    Rep Power
    22
    Are you doing this inside a function - in between script tags?
    Post you javascript.......
    ~ Joe Penn
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Posts
    92
    Rep Power
    14
    this is my whole javascript function:
    PHP Code:
    <SCRIPT TYPE="text/javascript">
    <!--
    function PopUp(TheURL, varWidth, varHeight) 
    {
        window.open(TheURL,"file","width=" + varWidth + ",height=" + varHeight + ",location=0,menubar=0,resizable=0,scrollbars=1,status=1,titlebar=1,toolbar=0");
        location.href = "localhost/kbj/shop_cart/user_cart.php?uid="+ <? echo $uid ?><? echo SID ?>;
    }
    //-->
    </SCRIPT>
  10. #6
  11. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Jun 2002
    Location
    Washington, DC
    Posts
    2,692
    Rep Power
    22
    Ok, I think your problem is the SID constant - if trans_session_id is enabled, it doesn't want to print it, so change it to ->
    PHP Code:
    location.href = "localhost/kbj/shop_cart/user_cart.php?uid="+ <? echo $uid ?>+<? echo session_name() . '=' session_id() ?>;
    It should be all good now....
    ~ Joe Penn
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Posts
    92
    Rep Power
    14
    no..its not working also...
  14. #8
  15. // no comment
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2001
    Posts
    1,645
    Rep Power
    40
    you may have forgotten to put the function session_start() on top of the page.
  16. #9
  17. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Jun 2002
    Location
    Washington, DC
    Posts
    2,692
    Rep Power
    22
    you may have forgotten to put the function session_start() on top of the page.
    Yes - you must of - it works fine on my side.....
    ~ Joe Penn
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2001
    Posts
    92
    Rep Power
    14
    nope, i have session_start() in my page.

    anyway, i found a way tat works for my page..

    PHP Code:
    location.href = "http://www.abc.com/cart.php?uid=<?=$uid ?>&<?=$SID ?>";
    thanks for all the help!!

IMN logo majestic logo threadwatch logo seochat tools logo