Passing a Class object into an Session?

Results 1 to 2 of 2

Thread: Passing a Class object into an Session?

  1. #1
    Calle Guest

    Default Passing a Class object into an Session?

    I´m trying to put a Class into a Session so I as will have as few database conn / session as possible.<BR><BR>ex.<BR>This is the first Page<BR>-------------------------------<BR>&#060;%<BR>Class clsMall<BR><BR> &#039 Dimma variabler<BR><BR> Private sDebug, sTitle, sCss, sJS<BR><BR> &#039 Class init<BR><BR> Private Sub Class_Initialize()<BR> &#039response.write "Class active"<BR> End Sub<BR><BR> &#039 Properties<BR><BR> Public Property Get Title()<BR> Title = sTitle<BR> End Property<BR><BR> Public Property Let Title(sValue)<BR> sTitle = sValue<BR> End Property<BR><BR> Public Property Get Css()<BR> Css = sCss<BR> End Property<BR><BR> Public Property Let Css(sValue)<BR> sCss = sValue<BR> End Property<BR><BR> Public Property Get JS()<BR> JS = sJS<BR> End Property<BR><BR> Public Property Let JS(sValue)<BR> sJS = sValue<BR> End Property<BR><BR> End Class<BR><BR><BR> Dim objMall<BR> Set objMall = new clsMall<BR><BR> objMall.Title = "TITEL ON PAGE."<BR> objMall.Css = "&#060;link rel=&#039stylesheet&#039 href=&#039/style.css&#039&#062;"<BR> objMall.JS = "&#060;script language=&#039javascript1.2&#039 src=&#039/js/script.js&#039&#062;&#060;/script&#062;"<BR><BR> Set session("objMall") = objMall<BR><BR><BR> Set objMall = Nothing<BR><BR><BR> response.write session("objMall").title & "&#060;hr&#062;<BR>%&#062;<BR><BR>And this is the second page<BR>--------------------------------<BR>&#060;%<BR>Set test = session("objMall")<BR> response.write test.title<BR> set test = Nothing<BR>%&#062;<BR>--------------------------------<BR><BR>I get an error on the second page saying that test isn&#039t an object.

  2. #2
    Join Date
    Dec 1969

    Default VBS Class instances are not objects...

    VBS lies to you. When you do New MyClass, it doesn&#039t *really* create any object. Now, the MS designers *could* have realized this and could have provided for storing these pseudo-objects in session values, but apparently they didn&#039t. So you are apparently hosed. It would be interesting to see if anybody finds a workaround (short of an ugly method whereby an object stores *itself* in the Session by storing the values of all its data members...which isn&#039t really all that ugly now that I think about it).<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts