Session in classic ASP

2019-04-27 11:34发布

问题:

I'w working on a project in classic ASP and I want to add, for example, some users for a temporary list and when I submit the form, this data will be save to DB.

I know how to work with this in asp.net, but not in classic asp.

Is it possible to create lists of users, for example, and manage this in a session?

thanks!

回答1:

yesa, you can use this, or the application state. one thing do note, you cant save objects in it, so you'll need to do some serialization if you want to store any complex things in it.


Session("username")="Donald Duck"
Session("age")=50

http://www.w3schools.com/ASP/asp_sessions.asp



回答2:

OPINION

You do have a couple of options of which a session is not one I would recommend. Just using form posting would be preferable just because of all the potential overhead with sessions in general. The most you would generally want to use them for is login data storage for a user logged into a site.

Not classic asp but good to know in all future endeavors with Sessions http://www.aspnet101.com/2010/10/asp-net-session-state-best-practices/

Answer http://www.w3schools.com/ASP/asp_sessions.asp


  //adding values to a session CSV
  //Yes I know these are not vbscript comments 
  //but I cant use vb comments   
  Session("someString") = "Value1,Value2,Value3"

  //Retrieving a value from a session
  Dim valsArr = Split(Session("someString"),",")

  //returning all content in a session object
  dim i
  For Each i in Session.Contents
    Response.Write(i & " ")
  Next