Results 1 to 9 of 9

Thread: Keeping Values through multiple Pages

  1. #1

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393
    Hi,
    I have a list box with items that I need to use as a WHERE clause in a SQL statement in a ASP page.

    The listbox items get transfered fine using the FORM ACTION tag to the next page, where my SQL statement is at.

    My problem is I need to keep track of the List box items for another 1 or 2 pages. How can I do this without using Session Variables? Inputting the values into a INPUT HIDDEN control?

    Thanks for the help.

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Posts
    102
    or session,
    or submit-request it thru the pages (input type=hidden or in the querystring),
    or store it in database.
    you can also use coockies.

    but why not use the session?
    and when you finish the serial of pages, reset the session variable ur using.
    itay.

  3. #3

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking Thanks Itlay

    Itlay,

    Thanks for the reply.

    The reason I kinda don't want to use the session is because I've heard it can get messy. Oh well.

    After further thinking, I think I will use the session variables.

    Quick question, I'm new to ASP and was wondering what the syntax is to reset a Session Variable something like:

    Session(MyVar) = ""

    Please let me know.

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  4. #4
    Lively Member
    Join Date
    Jan 2000
    Posts
    102
    you associate values (any type) to keys (strings) in the session.
    Session ("KeyName") = value;

    there are some messy stuff indeed with the session,
    but none of those "messy" stuff will happen if you
    keep it simple.

    simple:
    Session("SelectedOptions")="1,2,3"
    Session("SelectedOptions")=""
    Session("UserName")= ""+RS("UserName")

    not simple:
    Session("MyRecordSet") = RS;
    Session("UserName") = RS("UserName"); // !!!

    those are just sample, not coming to describe what
    is allowed/not allowed in the session object,
    but main thing, if you just store strings, there's
    nothing wrong with that.

    itay.

  5. #5

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking Thanks again

    Ok Cool.

    Thanks,
    I don't think you answered my question about resetting the variables.

    Do i need to say something like

    Set Session(myvar) to nothing
    or
    Session(myvar) = ""

    Please let me know.
    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  6. #6
    Lively Member
    Join Date
    Jan 2000
    Posts
    102
    you are right, but it doesn't matter.
    you can always use check like this:
    if (""+Session("MyKey")=="undefined")
    {
    // then it's undefined
    }
    else
    {
    // you can check for whatever value.
    // like "done" or "1,2,3" or "no" or even "yes"
    // or "undefined"
    }

    important to note the difference between
    Session("Key")
    and:
    ""+Session("Key")

    if you always setting strings as values,
    then always check for ""+Sess...

    explicitly setting session variable to undefined?
    i don't know how. but again, don't let this bother you.

    itay.

    [Edited by itay222 on 01-04-2001 at 08:42 AM]

  7. #7

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking Thank You

    Itlay,
    You've been a big help.
    Thanks.

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  8. #8
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    The problem with using the Session object variables is that it will not allow your app to scale beyond one server. If you are creating a serious web app that will receive ALOT of traffic, and require a server farm, you will not be able to use the session object because each page MUST be stateless because the load balancing software will not necessarily forward the request to the same server each time throughout a session. Since session objects are stored in a server's RAM, they are not accessable to other servers only themselves.
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  9. #9
    Guest
    There will not be a problem using session variables in a web farm if all of the links and redirections on your pages use local paths and not full http headers:

    response.redirect "/HomeDir/Login.Asp rather than

    response.redirect "Http://yoursite.com/login.asp"

Posting Permissions

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



Click Here to Expand Forum to Full Width