Click to See Complete Forum and Search --> : Keeping Values through multiple Pages
JazzBass
Jan 4th, 2001, 06:32 AM
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
itay222
Jan 4th, 2001, 06:37 AM
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.
JazzBass
Jan 4th, 2001, 07:07 AM
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
itay222
Jan 4th, 2001, 07:14 AM
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.
JazzBass
Jan 4th, 2001, 07:24 AM
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
itay222
Jan 4th, 2001, 07:38 AM
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]
JazzBass
Jan 4th, 2001, 07:46 AM
Itlay,
You've been a big help.
Thanks.
JazzBass
monte96
Jan 4th, 2001, 09:23 AM
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.
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"
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.