How to read and write session values in javascript
7 Answers
If you speak about server-side session values, there's no other way than to somehow communicate with the server (e.g. with an asynchronous callback where you would read/write them with some method).
For simulation of client-side session variables, you might want to have a look here ;)
Comments
A bit more context could be useful in understanding what exactly you're trying to achieve. As the session is held on the server, the only way to "instantly" communicate with it would be using AJAX calls.
This being not such a common way of operating maybe explaining your situation may help in giving you alternative, more common ways of doing what you need.
Comments
You can't because session variables are actually saved to a file on the server only. The only thing your browser knows about the session is the session id, which is saved into a cookie.
This is the whole point with sessions. The variables are safe because no one on the outside can read them. If you want variables readable by the browser, consider using cookies instead.