Forums Archive Index > SmartMenus 5 > Help, please: Passing session IDs as variables?
Date: 8 Dec 2004 4:53 am
Hello,
when I try adding SmartMenus to a dynamic website by referencing the JavaScript files externally, I would like to pass the current session ID as a parameter to the JavaScript method that builds the menus so that they are appended to the links in the menu, i.e.
Code:
U:'/cat/70060000000/med' would become
Code:
U:'/cat/70060000000/med&sid=' + mySID
However, I couldn't figure out for the life of me how to pass that parameter from the page showing the menu to the respective Code:
s_add method in s_arrays.js.
Is there any way to achieve this without embedding the whole shebang directly into the page and dynamizing it with Strings?
Your hellp with this is greatly appreciated.
Thanks in advance for any hints.
Ralph
Date: 9 Dec 2004 11:35 am
Well, the easiest solution, I can think of at the moment, is to define a JavaScript variable containing your session ID. You can place it in the headers of the pages (for instance in the block with the SmartMenus header code). In PHP it might look like this:
Code:
<script type="text/javascript" language="JavaScript">
<!--
function s_show(){return false}
function s_hide(){return false}
if(window.event+''=='undefined')event=0
mySID='<?= $PHPSESSID ?>'
//-->
</script>
And then you can have this:
Code:
U:'/cat/70060000000/med&sid=' + mySID
without any problems in the static "s_arrays.js" file.