Saving Objects in Session variables 
Author Message
 Saving Objects in Session variables

What is the syntax for putting an Object in a Session
variable then taking the object out? Do I need a SET in
all cases or what?

Is this correct:

Set Session("MyObject") = MyObject
Set MyObject = Session("MyObject")

Or is this:

Session("MyObject") = MyObject
Set MyObject = Session("MyObject")



Sun, 06 Feb 2005 02:40:34 GMT  
 Saving Objects in Session variables
I forgot to mention that these are user-defined objects.
Quote:
>-----Original Message-----
>What is the syntax for putting an Object in a Session
>variable then taking the object out? Do I need a SET in
>all cases or what?

>Is this correct:

>Set Session("MyObject") = MyObject
>Set MyObject = Session("MyObject")

>Or is this:

>Session("MyObject") = MyObject
>Set MyObject = Session("MyObject")

>.



Sun, 06 Feb 2005 03:05:31 GMT  
 Saving Objects in Session variables

Quote:
>Is this correct:

>Set Session("MyObject") = MyObject
>Set MyObject = Session("MyObject")

Yes.

Quote:

>Or is this:

>Session("MyObject") = MyObject

No

Quote:
>Set MyObject = Session("MyObject")

Yes again.

You really should not store objects in session variables as there is no
way to guarantee their termination.  You can set them to nothing in the
Session end event, but that event does not fire 100% of the time (though
I have found in my apps that it is pretty close to 100%.)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 06 Feb 2005 03:42:07 GMT  
 Saving Objects in Session variables

Quote:

> I forgot to mention that these are user-defined objects.

If by this you mean VBScript class based objects, then you can't store them outside the scope of the page that created them...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sun, 06 Feb 2005 03:55:36 GMT  
 Saving Objects in Session variables
How else can I save the state of complicated variable
structures?
Quote:
>-----Original Message-----
>Message unavailable



Tue, 08 Feb 2005 22:44:51 GMT  
 Saving Objects in Session variables

Quote:

> How else can I save the state of complicated variable
> structures?

Serialize them to some text form which can be saved in Session/Application scope and later deserialized back to an object instance.  

XML would be my choice.  In fact, you can even use an Msxml2.FreeThreadedDOMDocument instance at Session/Application scope. All of this assumes you have data only object instances (i.e., no object methods).

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Wed, 09 Feb 2005 02:35:58 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Save array in Session object

2. Save array in Session object

3. Having trouble saving array in Session object

4. Save array in Session object

5. ScriptingContext object and asp session variables

6. Storing objects in ASP session variables

7. Persisting an ADO2.5 Stream object to a Session-variable

8. How to pass the value of a variable to Session object

9. Server side JScript objects stored in Session variables

10. Class object and Session variable

11. Class Objects stored into session variables, not possible?

12. SESSION Object Variables

 

 
Powered by phpBB® Forum Software