Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application variables vs Session variables

Status
Not open for further replies.

RAS56

Programmer
Sep 28, 2001
24
US
I read through a posting and replies that helped me to understand the problems associated with using session variables, especially if cookies are turned off on the client machine. Would the same problem exist with application variables? (I realize I can only put things that will be common to every user there.)

Also, any thoughts on the overhead of using application variables vs reading those values out of a sql database on each page.

Thanks
 
Application variables have application scope rather than session scope. This means that the value in a single application variable named "mycar" can be read equally from any session connected. If you change the value from one session it is changed for all sessions.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Thanks. I understood that application variables would be the same for all users. I guess I didn't phrase my question very well. Do application variables depend on cookies like session variables?

I suspect they do not but I don't want any supprises.
 
They don't need cookies. -Phil
fillup07@hotmail.com
If my post was helpful, please give me a star!
 
No, since they are "application" scope variables that don't differ depending on user, then no part of them is dependant on knowing which user is connected. So there would be no cookies involved. If I remember correctly application variables are stored in hard memory rather than RAM lik session variables, but I could be incorrect as it has been quite some time since I used them. If I am correct (I think I am) than the differance would be less of a load on your memory with a slightly slower access time.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Hi,
I have a question about session vars too.
How to use session vars to authenticate users?
For example:
if one user is logged in - Session("userID") will get his ID value.
Then, if another person is trying to go to the password protected page and types in his name and password what happens with the first user?
Session("userID") will get a new value.
Is there a good way of using session variables for authenticating and storing information about each user (create an array and store it there, maybe?) or I have to connect to DB on each page for authentication or pass Form/Srting variables everywhere?
Thank you.
 
When a user logs in, use this code (once you have the username and stuff)
Session("userID") = username
Then on any page you can get the user name by using Session("userID")

-Phil
fillup07@hotmail.com
If my post was helpful, please give me a star!
 
axa777, as the session variable is unique to each session (or user if it makes it easier to understand), then when another person logs in in your example nothing happens. The system continues to function. These session variables are created unique to each independant session (or user) connected to your server, so changing a session variable for one session (or user) does not change it for all sessions (... or users!).

-GTM Consult, Home of USITE-
-=
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top