开发者

Javascript Equivalent for Session Variables in VB?

开发者 https://www.devze.com 2023-03-09 18:59 出处:网络
I have some VB code, which I can no longer use (long story). It goes like this: Session.Contents(\"LetterV开发者_如何学JAVAariables\") = Nothing

I have some VB code, which I can no longer use (long story). It goes like this:

Session.Contents("LetterV开发者_如何学JAVAariables") = Nothing

Is there a javascript equivalent?

Thanks,

Jason.


There is no direct equivalent, since javascript runs client side, not server side.

You can use cookies for small amounts of data, and with HTML you can use local storage. These allow you to share data across pages (on the same domain) using javascript, but unless using session cookies or coding specifically for it, these will persist beyond a session.


You have several options here:

  1. Within JavaScript, you'd need to leverage objects to implement state management. Just google around for "state management javascript" and I'm sure you'll find something helpful. But keep in mind the life of that session - for example, in ASP.NET the session typically lives on until the the browser window is closed. But via JavaScript it's only until that page is either closed or refreshed.
  2. Use cookies to manage session state, which lives on until the expiration of said cookies (or until user deletes the cookies).
  3. Continue to use ASP.NET session state, but access it via AJAX calls.
0

精彩评论

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

关注公众号