title: How to pass a global value from C to LUA?
body: <p>Recently I manged to embed LUA in my C application, what I'm trying to do now is thatI have a value (Session_ID) I want to pass from C function to a LUA script, so that it can be used by LUA script to Call a function back in C.</p>
  
  <p>I have no problem loading LUA script in C and running it (using lua_pcall), and I have no problem as well to call the C function from inside LUA, my current problem is passing global variable back and forth.</p>
  
  <p>For example:</p>
  
  <p><em><strong>At C side (test.c):</em></strong></p>
  
  <pre><code>session_id = 1;
  luabc_sz = rlen;
  result = lua_load(L, luaByteCodeReader, file, "script", "bt");      
  if( lua_pcall(L, 0, 0, 0) != 0 )
  </code></pre>
  
  <p>Where file is the array containing the LUA script (script.lua).</p>
  
  <p><em><strong>At Lua side script.lua):</em></strong></p>
  
  <pre><code>print "Start"
  for i=1,10 do
    print(i, **session_id**)
  end
  print "End"
  </code></pre>
  
  <p><em><strong>"print"</em></strong> is overwritten by my own function, and I want to pas the <strong>session_id</strong> to it.
  So the complete scenario is that I have the <strong>session_id</strong> in the c function, which I want to pass to the LUA script which will use it later to call the print function which is written in C.</p>
  
  <p>Any help with that :)?</p>