when to use the Set keyword

Results 1 to 2 of 2

Thread: when to use the Set keyword

  1. #1
    biner Guest

    Default when to use the Set keyword

    The powers that be have decided to hang an object off of the session (I know this may cause performance issues). I would normally do it this way in vbscript:<BR>Dim oUser<BR>Set oUser = CreateObject("oUser.User")<BR>Session("CurrentUser ") = oUser<BR>but a gentleman I work with insists that I use the SET keyword when assigning the object to the session like this:<BR>Set Session("CurrentUser") = oUser<BR>I don&#039t think this is necessary since the session object is inherent. Which way is right?<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: when to use the Set keyword

    Well,<BR><BR>I am know expert, but I read in the ASP Objects reference about this very thing. If I remember correctly, you should always use SET if you store an object in the Session object and use VBScript as your primary scripting language, you must use the Set keyword. This is illustrated in the following script.<BR><BR>&#060;&#037; Set Session("Obj1") = Server.CreateObject("MyComponent.class1") &#037;&#062;<BR> <BR>You can then call the methods and properties exposed by MyComponent.class1 on subsequent Web pages, by using the following.<BR><BR>&#060;&#037; Session("Obj1").MyMethod &#037;&#062;<BR> <BR>Or by extracting a local copy of the object and using the following.<BR><BR>&#060;&#037; <BR>Set MyLocalObj1 = Session("Obj1") <BR>MyLocalObj1.MyObjMethod<BR>&#037;&#062;<BR> <BR>nice deal<BR>skol <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