Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session in classic ASP

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!

like image 798
André Miranda Avatar asked Oct 22 '10 12:10

André Miranda


People also ask

What is session in ASP?

In ASP.NET session is a state that is used to store and retrieve values of a user. It helps to identify requests from the same browser during a time period (session). It is used to store value for the particular time session. By default, ASP.NET session state is enabled for all ASP.NET applications.


2 Answers

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

like image 62
jasper Avatar answered Oct 24 '22 14:10

jasper


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

like image 45
Terrance Avatar answered Oct 24 '22 13:10

Terrance