Advantages and disadvantages of using session variables in session| variable ASP
(Author: Green Apple Computer Studio)
Many people use session variables to develop ASP (Active Server Pages). These variables are very similar to variables that are common in any programming language and have the same advantages and drawbacks as common variables. Any command requires run time and storage space (even Goto ' s statement), and the session variable also needs its own run-time and storage space. Excessive use of Session variables can result in code redundancy and increased server operating costs below are some of the main ideas and experiences of my personal use of session variables.
If you want to pass a variable between many Web pages, you can simplify the problem by using the session variable rather than passing the variable by querystring.
To make a Web site user-ready, consider using the session variable. Every visitor to your site has a user experience, and based on this, with the use of LDAP and such as Ms Site Server, you no longer have to place all the user processes into the session variable, which is dependent on the user's preferences.
You can use the session variable directly when you want to use it, rather than declaring it in advance, which is close to the use of variables in VB. After you use it, you do not have to consider releasing it because it is automatically released.
The session variable and the cookie are of the same type. If a user sets the browser to be incompatible with any cookies, the user cannot use the session variable!
When a user accesses a page, the running environment of each session variable is generated automatically, and these session variables remain for 20 minutes after the user leaves the page! (In fact, these variables can always be retained to "timeout".) The length of time for "timeout" is set by the Web server administrator. The variables on some sites only last 3 minutes, some 10 minutes, and others remain to the default value of 20 minutes. So, if you place a larger object in the session (such as ADO recordsets,connections, etc.), then there's trouble! As the amount of site traffic increases, the server will not function properly!
Because the creation of session variables is very arbitrary, can be invoked at any time, do not require the developer to do accurate processing, so overuse of session variables will cause code unreadable and difficult to maintain.
Although "You can use the session variable directly at any time you want to use it without having to declare it beforehand, this approach is close to the use of variables in VB." After you use it, you do not have to consider releasing it, as it will automatically release. But, "who" thought there? What is the meaning of a variable? It all becomes less clear.
The use of Session variables has both advantages and disadvantages. In my personal opinion, it's best to use less, but using them in some places really makes web development much simpler. Whether to use the session variable depends entirely on the individual's needs, regardless of whether it is used or not, to consider its pros and cons beforehand