Many people use session variables to develop ASP (Active Server Pages). These variables are very similar to common variables in any programming language and have the same advantages and drawbacks as common variables. Any command requires run time and storage space (even the Goto ' s statement), and the session variable also requires its own run time and storage space. Excessive use of session variables can lead to the inability to code redundancy and to increase the cost of running the server the following are some of my main points of view and experience of using session variables.
Advantages
If you want to pass a variable across many Web pages, it is easier to use the session variable than passing the variable through querystring.
To make a Web site user-ready, consider using the session variable. Every visitor to your site has a user experience, and with the use of LDAP and such as MS Site Server, it is no longer necessary to place all of the user-based processes into session variables, which is dependent on the user's preferences. Shanghai Treatment Impotence Hospital}
You can use the session variable directly at any time you want to use it, rather than declaring it in advance, which is close to the use of variables in VB. After you have finished using it, you do not have to consider releasing it, as it will be freed automatically.
Disadvantages
The session variable and the cookie are of the same type. If a user sets the browser to be incompatible with any cookie, the user cannot use the session variable!
When a user accesses a page, the running environment of each session variable is automatically generated, and these session variables remain for 20 minutes after the user leaves the page! (In fact, these variables can always be kept to "timeout".) The length of time "Timeout" is set by the Web server administrator. The variables on some sites lasted only 3 minutes, some 10 minutes, and others to the default value of 20 minutes. So, if you put a larger object in the session (such as ADO recordsets,connections, etc.), then there's a problem! The server will not work as the site visits increase!
Because creating session variables is very arbitrary, can be called at any time, do not require the developer to do the precise processing, so, excessive use of the session variable will cause the code unreadable and poorly maintained.
Although "You can use the session variable directly at any time you want to use it, rather than declaring it in advance, this approach is similar to the use of variables in VB." After you have finished using it, you do not have to consider releasing it, as it will automatically release ". But, "who" thinks of it? What does the variable mean? These are not very clear.
Summarize
The use of Session variables has both advantages and disadvantages. In my personal opinion, it's best to use less, but in some places it can really make web development much easier. The use of the session variable depends entirely on the individual's needs, regardless of whether it is used or not, the pros and cons should be considered beforehand
Advantages and disadvantages of using session variables in ASP