You need to understand the asp.net page lifecycle. What your code is doing is generating html when it is first requested from the server and sending that static html to the client. So if you had "Hello" in Session["test"] when the page was requested then it would generate the following js;
var s = 'Hello';
That is what is executed in the browser so if the Session variable is amended elsewhere that change is not going to reflect in your original page until that page is refreshed, as your .net code isn't "running inside" the browser, it is only used to generate the initial html to send to the browser.