开发者

Session value in Javascript

How to re开发者_StackOverflowad and write session values in javascript


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 ;)


you can't write directly to a server side session var with javascript. Assuming you are not using Ajax here.


Session variables reside on the server and as I'm sure you are aware, Javascript is client-side.


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.


HTTP session vars are controlled by the server, JavaScript runs client side, and as such cannot modify the vars directly. Meaning this isn't possible using only Javascript


Java is client side scripting language. The client's web-browser does not know anything about session!

All you can do is to use cookies to store values which can be accessed across web-pages.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜