Advantages and disadvantages of using session variables in ASP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.