Ah, I see. You want it inline, outside the functions. First of all, the 2 lines session.id and session.name at the very top will probably cause trouble all by themselves. Why don't you delete them?
I suppose the rest of the code should work, but perhaps you should put the rest of the code inside a function and use routes to remap URL? Anyway, I'm still curious what results you got?

