Stored array in a Session Variable?

Results 1 to 3 of 3

Thread: Stored array in a Session Variable?

  1. #1
    Phil Forbes Guest

    Default Stored array in a Session Variable?

    Ok, I already realize I&#039m asking for trouble. I know that Session Variables are evil, but I need to know if it&#039s possible to save an array as a Session Variable, and if so how do you go about doing it.<BR><BR>Thanks!<BR><BR>Phil Forbes

  2. #2
    Shedao Shai Guest

    Default RE: Stored array in a Session Variable?

    A common misconception is that session variables are evil. But they do serve a useful function. The main thing to keep in mind is that each variable will need a certain amount of memory and you should treat it accordingly with resources, etc. Sometimes session vars are the best solution.<BR><BR><BR>That being said - <BR>You can simply assign a array as the value of a session variable like so:<BR>&#060;%<BR>&#039simple array below just for this example:<BR>dim arrayName()<BR>redim arrayName(4)<BR>arrayName(0) = "Ian"<BR>arrayName(1) = "Stallings"<BR>arrayName(2) = "is"<BR>arrayName(3) = "a"<BR>arrayName(4) = "dork"<BR><BR>&#039here is where we assign the array to the session var:<BR>Session("arrayName") = arrayName<BR>%&#062;<BR><BR>BUT, when you want to alter a value in this array you must place the array into a local variable like so:<BR><BR>&#060;%<BR><BR>dim localArray<BR>localArray = Session("arrayName")<BR>&#039this would write "dork":<BR>Response.write(localArray(4))<BR><BR>&# 039we change the value below:<BR>localArray(4) = "geek"<BR><BR>&#039then we update the session variable:<BR>Session("arrayName") = localArray<BR><BR>%&#062;<BR><BR>I hope this helps.<BR><BR>

  3. #3
    Phil Forbes Guest

    Default RE: Stored array in a Session Variable?


Posting Permissions

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