|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Session Variable vs. Application variable
I'm looking for opinions. Which is better for load time, organization, server drain, etc. session variables or application variables?
|
|
#2
|
|||
|
|||
|
Both are stored in memory so both are very fast. That said, I think you may want to do some additional reading, because session variables and application variables are meant to solve two totally different types of problems.
A session variable is specific to a single user, based on a cookie or an identifier passed in the URL. This would be something like a shopping cart or user login information. An application variable is shared across all users of a single application (based on the name used in the cfapplication tag). So this would be useless for a shopping cart. But might be appropriate for caching the site menu, or creating a Singleton instance of a CFC.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
||||
|
||||
|
Dont forget about Cookies, sometimes sessions dont retain, i use this alot
<CFIF isdefined("Session.Whatever")> <CFSET COOKIE.Whatever> </CFIF> This is when Kiteless says "be careful with cookies not all users can utilize them" Ps he would be right |
|
#4
|
|||
|
|||
|
Not only that but there are severe limits on the size of a cookie, as well as the number of cookies the browser will allow you to set per domain. Finally, trying to store large data sets or CFC instances are impossible with a cookie. Cookies are meant for storing extremely basic things like a session identifier, date of last visit, etc.
|
|
#5
|
|||
|
|||
|
Another example between a applicaton and session variable is we use a application variable to set our company name so that we can display it on various relavant pages on our site
As our name does not change very often, this is a great way to use it for us because we can use the variable but do not have to create a include for this small piece of data. Where for a registration form that we have on our site we create a session so that we can store different piece of data while the are progressing through the step by step form. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Session Variable vs. Application variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|