I need to save a class object in a Session variable. Good? Bad?

Ask a Question related to ASP Components, Design and Development.

  1. #1

    Default I need to save a class object in a Session variable. Good? Bad?

    Hi,

    I am in a situation where I am forced into passing a class object around
    between a bunch of pages. The only way that I can figure out how to do it
    is storing the object instance in a Session variable. I believe that this
    is possible, but my concern is whether it gets destroyed at end of session.

    Any comments?

    Thanks.

    Larry Woods


    Larry Woods Guest

  2. Similar Questions and Discussions

    1. Variable Scope Within a Object Class
      I am trying to create a class similar to the one shown below. I am having a hard time figuring out why "someProperty" is returned as undefined. I...
    2. Loading of Class Object passed via PHP Session fails!
      Hello! I try to use PHP session function, and it doesn't work properly. :-( I want to pass a whole object from site A to site B to minimize...
    3. HELP: My ASP class object is crippled if I save it in a session collection
      I am using ASP3.0 and IIS5 I want to have OOP so I have define a class call Employee with property 'fullName' and methods like getFullName(). ...
    4. ASP class-session variable
      Hiya - Big puzzler for me. Code Below I create a class. I save it to a session variable. Then, I retrieve the session variable back into a new...
    5. class -session variable
      Hi, I want to do things this way: I have a bunch of stuff that I want to keep track of while a user is connected to the site. Maybe 50 little...
  3. #2

    Default Re: I need to save a class object in a Session variable. Good? Bad?

    Most of the advice you'll get will probably be a variation on this:
    [url]http://www.aspfaq.com/show.asp?id=2053[/url]

    Is there any way you can use a database table to store all the relevant
    data from the object, and just store the ID for that row in a session
    variable? You could create the object with the appropriate data on each
    page, by querying the data, and store the data just before you destroy
    the object at the bottom of the page. (I'd use include files for this.)
    You could make the ID into a cookie if you wanted the data to persist
    past the session.

    "Larry Woods" <larry@lwoods.com> wrote in message
    news:eRhYcL4WDHA.2376@TK2MSFTNGP11.phx.gbl...
    > Hi,
    >
    > I am in a situation where I am forced into passing a class object
    around
    > between a bunch of pages. The only way that I can figure out how to
    do it
    > is storing the object instance in a Session variable. I believe that
    this
    > is possible, but my concern is whether it gets destroyed at end of
    session.


    Kris Eiben Guest

  4. #3

    Default Re: I need to save a class object in a Session variable. Good? Bad?

    Yeah, Kris. I knew the answer to "store an object in a Session variable" is
    "NO!", but I have a BUNCH of arrays, variables that are being used in the
    component. I have decided to get the values thru GET properties, store the
    values in Session variables. I'll then recreate the object and reload the
    variables via LET properties when I need the object again. Bunch of typing,
    but safest.

    Thanks,

    Larry Woods

    "Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote in message
    news:Oai7Zi4WDHA.2424@TK2MSFTNGP12.phx.gbl...
    > Most of the advice you'll get will probably be a variation on this:
    > [url]http://www.aspfaq.com/show.asp?id=2053[/url]
    >
    > Is there any way you can use a database table to store all the relevant
    > data from the object, and just store the ID for that row in a session
    > variable? You could create the object with the appropriate data on each
    > page, by querying the data, and store the data just before you destroy
    > the object at the bottom of the page. (I'd use include files for this.)
    > You could make the ID into a cookie if you wanted the data to persist
    > past the session.
    >
    > "Larry Woods" <larry@lwoods.com> wrote in message
    > news:eRhYcL4WDHA.2376@TK2MSFTNGP11.phx.gbl...
    > > Hi,
    > >
    > > I am in a situation where I am forced into passing a class object
    > around
    > > between a bunch of pages. The only way that I can figure out how to
    > do it
    > > is storing the object instance in a Session variable. I believe that
    > this
    > > is possible, but my concern is whether it gets destroyed at end of
    > session.
    >
    >

    Larry Woods Guest

  5. #4

    Default Re: I need to save a class object in a Session variable. Good? Bad?

    That is the best way to do it really. Rather than lots of
    properties you could try using a serialise technicque
    where you get your object to return its data as an XML
    string, and give it the ablity to restore itself from this
    xml also.
    >-----Original Message-----
    >Yeah, Kris. I knew the answer to "store an object in a
    Session variable" is
    >"NO!", but I have a BUNCH of arrays, variables that are
    being used in the
    >component. I have decided to get the values thru GET
    properties, store the
    >values in Session variables. I'll then recreate the
    object and reload the
    >variables via LET properties when I need the object
    again. Bunch of typing,
    >but safest.
    >
    >Thanks,
    >
    >Larry Woods
    >
    >"Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote in
    message
    >news:Oai7Zi4WDHA.2424@TK2MSFTNGP12.phx.gbl...
    >> Most of the advice you'll get will probably be a
    variation on this:
    >> [url]http://www.aspfaq.com/show.asp?id=2053[/url]
    >>
    >> Is there any way you can use a database table to store
    all the relevant
    >> data from the object, and just store the ID for that
    row in a session
    >> variable? You could create the object with the
    appropriate data on each
    >> page, by querying the data, and store the data just
    before you destroy
    >> the object at the bottom of the page. (I'd use include
    files for this.)
    >> You could make the ID into a cookie if you wanted the
    data to persist
    >> past the session.
    >>
    >> "Larry Woods" <larry@lwoods.com> wrote in message
    >> news:eRhYcL4WDHA.2376@TK2MSFTNGP11.phx.gbl...
    >> > Hi,
    >> >
    >> > I am in a situation where I am forced into passing a
    class object
    >> around
    >> > between a bunch of pages. The only way that I can
    figure out how to
    >> do it
    >> > is storing the object instance in a Session
    variable. I believe that
    >> this
    >> > is possible, but my concern is whether it gets
    destroyed at end of
    >> session.
    >>
    >>
    >
    >
    >.
    >
    Adrian Forbes - MVP Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139