I don't think session object can be written by javascript. it's server side. If I am getting your problem right, I guess you wanna share data between client side (to --->

and server side
You can use a hidden html textbox which is populated by javascript, and when form submits you can access that textbox from your server side code.
Or use the standard querystring approach (Again a messy thing).