store session variable and access it through javascript?
Accessing a session variable in Drupal is not different from how it is done with plain PHP: with $_SESSION.

As for reading them with JavaScript, it is enough to use code similar to the following one.

// PHP
drupal_add_js(array('myModule' =&gt; array('key' =&gt; $_SESSION['key'])), 'setting');


// JavaScript
key = Drupal.settings.myModule.key;