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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between a Session and Application variable

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
what are the differences between these two guys and do I know which is which? for example...the code snipet I used earlier using VBScript in the body of my .ASP page:

<%
dim name
name="ME"
response.write(name)
%>

what kind of variable is name in the scenario?

Thanks,
 
local, to the script or if delcared within a sub or function, local to only that sub or function...

sessions vars are declared with

session("myVar") = "something"

and is available to any page that using that session("myVar") ie...

newPageVar = session("myVar")

These vars are limited to the life of the session, until the user closes the browser or logs off (if that functionality is implemented in the application

Application vars are set in the global.asa file and are set for the lifetime of the application (or at least till the server is shut down)

example of this would be a hit counter where it needs to exist across multiple sessions and keep going for the life of the application

hth


Bastien

Cat, the other other white meat
 
and to answer the question in your post .. name is variable type string because you defined the variable without an "AS" statement like :
dim name as integer
or
dim name as string

then you assigned a string value to it hence defining it as a string variable with :
name="me
 
here's what I am trying to do and not getting any where with it. Obviously doing it all wrong.

I am trying to set a variable and then have my content source only pull those records out of the database that match that criteria.

I'm using Adobe GoLive and just not seeming to make any grounds.
 
eh ?

if its say a customer returning to shop, hey can log in and then you can store their customer id in a session value that way (personalized page layout whatever) session only applies to the PER instance session of a user, if the user opens 2 browser instances ( non parent/child relationship ) there will be 2 seperate session environments unless you set up the website to support merging them via log in, session and cookie, but even then the sessions will still be seperate, you'll just be treating the 2 as one.

if you want a hit counter like mentioned before you want an application variable.

if you'd like a concurrent connections counter ( how many people currently browsing ) you'd want an application variable

if you want a web site wide value for all users when they hit they get a specific DB response, use application, if you have different people connecting and you want to store temporarily what DB response you want for each of them ( same or with the option of different ) use session values

as for adobe golive, sorry cant help you there, i use homesite and notepad to write everything, anything wysiwyg tends to mess up anything i write, so i avoid them at all costs.
 
So you don't need either a Session or an Application variable, then.

You just need (as bastienk described) a standard variable, which either has page scope (declared outside a sub or function and visible to all) or local (declared inside a sub or function and only visible there).

I haven't used GoLivwe either so don't know how you are trying to build your database query code. If you can post some code that would probably help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top