asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search








Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Are Session Variables Satan's Spawn?
By 15 Seconds Discussion List
Rating: 3.7 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article

    Adam Would Just Like To Know:

    How can I set a cookie to expire in 15 minutes?

    I know to use Response.Cookies(cookiename).Expires = Now() + ?????????

    Decius Innocently Replies:

    Have you considered using session variables? Session variables' default is 20 minutes. However you can change this to 15 minutes.

    Rob Shouts:

    session variables are the devil's spawn!

    Anders Agrees:

    If session variables makes your world go round, by all means use them, but I agree they should be used with care. However, I don't see why one always would want to do an extremely hardcore workaround in order to get the same flexibility as session variables offer - that is, use a guid or something to represent user-state on the server.

    Would you store everything in a querystring? and then transfer that querystring from page to page? Really cumbersome, if you have access to session variables!

    Rob Preaches:

    Personally I would only limit myself to the session object nightmare when

    1. cookies don't matter
    2. deployed for a very limited environment, and scalability is not a concern (Intranet)

    Once you've done it, and you did it well enough, it's very simple just to plop your object in & setup a couple of tables to enable fully scalable and flexible session support.

    Nick Asks:

    Am I right in saying that session variables are bound to a browser, i.e. One browser can't read the session variables of another!?

    How is this binding implemented automatically by IIS? It uses cookies, right? What if the user has cookies turned off then how does it cope with that?

    Rob Professes:

    Session variables are bound to one server. They are sitting in the server's memory that created it. That is the main reason why they inhibit scalability. In a truly scalable solution, each request is routed to the first available server, regardless of its previous usage of the web farm. But there are solutions (LocalDirector) which will route each user's concurrent requests to the same machine, which it hits on the first time, thus you will be able to use session variables and they will persist. But, LocalDirector and other packages are very expensive, Session variables can consume large amounts of memory (depending on the usage of course), and you will be basically implementing a half-assed solution...It could be very possible that the load balancing software could route incoming request to the same machine, over time (statistically possible), which means improperly allocated resources. And also, one major thing with the choice to move to a load balanced environment is to have no single point of failure (i.e., being able to unplug one machine, and have things still run normally). Well give the above situation, unplugging one machine would cause tremendous session losses for your users. (basically just plain out pissing them off) -kiss that $10,000 sale good bye, not to mention the negative word of mouth advertising you would get.

    Secondly...Session variable are maintained by a non-persistent cookie. I know that in IE, if you hit Control-N, these non-persistent cookies will carry forth to the new browser. But if you double click the IE icon on your desktop, and start a whole new IE, these cookies will not be in the new browser.

    Cookies need to be enabled. Session state will not be maintained using the session object if the user has chosen to turn of cookie support. So basically you're automatically excluding every American government employee. (didn't the American Gov. set a standard that they cannot use or accept cookies? I think they did...?!!)

    Nick Continues the Inquiry:

    So unless the web system is to be used in a specific, dictable environment it's best not to use cookies and have the session ID being passes around in the URLs or as hidden form field. Then have the variables come from data!?

    Rob Answers:

    Yes..basically..you persist the user by a UUID (unique user id). This is passed around all over the place (of if you want, use cookies..your call)... and then that relates back to the database, which hold the user's information.

    You, of course, would need to set it up for anonymous users, registered users, etc...

    It takes a bit of time, initially, to setup the environment and create a basic COM object that will handle the logging in, etc... but once you've did it once, the rest is nothing. I think it took me about 3 hours to do it from start to finish.

    Check these links:

    http://www.aspalliance.com/nothingmn or http://www.aspfree.com/authors/robert

    both have some *older* articles on this there...review them...

    I will be updating them this weekend, with most likely full source which you all can "borrow"....

    also:

    http://www.aspfree.com/authors/robert/faq.asp?id=1

    and

    http://www.aspfree.com/devlinks
    Category: State/Session Management

    might prove useful

    This conversation string was taken from the 15Seconds ASP Listserv on 3/6/01. If you have an ASP-related question or would like to share some of your knowledge with others, you may join the list by clicking here

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Supporting Products/Tools
    ASP Session Manager
    ASP Session Manager works by inserting 2 lines of code at the top of your ASP script and have the session serialize itself to any DBMS. There are three licenses available, ranging from a single binary to an enterprise ISP license with source code.
    [Top]
    SA-Session Pro
    Web farm getting out of control? You need scalability! SA-SessionPro is a simple, yet very powerful means of making your ASP application persistent--share and save information on a per-user, per-application, per-server, or per network basis. SA-Session is like the built in Session object that comes with the IIS Server, except it allows developers more flexibility. It has the ability to store information without expiration and the ability to preserve session state across multiple machines in a web farm.
    [Top]
    SessionFarm
    SessionFarm is an Active Server Pages component that allows you to manage session state on multiple servers in a web-farm. SessionFarm utilizes the built-in IIS Session object which means you don't have to learn new methods and objects. The IIS Session object is stored on either a file-share or a SQL database using optimized stored procedures.

    SessionFarm requires no rewriting of your existing code and works by supplementing the existing IIS Session.

    For code samples, see http://www.groat.com/sessionfarm/implement.asp.

    [Top]
    Other Articles
    Dec 30, 1999 - Using Hidden FRAMES to Hold Data or Maintain State
    Hidden frames allow users to maintain almost any kind of data, and maintain state easily and reliably. Mark Burnham's article uses a shopping cart scenario to show simple ways to read and write data, and call functions from a hidden frame. Visible frames can be loaded with virtually anything, but these hidden frames will always be there, holding data until it's needed.
    [Read This Article]  [Top]
    Dec 23, 1999 - How to Detect If Cookies Are ON
    Mark Burnham offers a quick and easy way to check if your browser accepts cookies. If it does, then you're clear to use session variables when writing ASP scripts. Just follow the sample code to learn how to copy a form and compare SessionIDs.
    [Read This Article]  [Top]
    Jul 1, 1999 - Avoid the Pitfalls of Sessions with the LookupTable
    Brian Reagan demonstrates how to use the LookupTable object to avoid problems with session objects timing out. Read this in-depth article and learn the tricks of the trade.
    [Read This Article]  [Top]
    Jan 14, 1999 - Easy Application State Securely
    This article by Dmitry Khanine shows how to make your web site 100-percent secure when maintain your application state.
    [Read This Article]  [Top]
    Jan 8, 1998 - Maintaining State
    In this issue we will discuss two built in states of the Internet Information Server, session and application. We will also continue where we left off with the Nov 08, 1997 - Sharing Cookies Across Domains Issue, and show how to maintain session state across multiple servers in a web farm. Also discussed, will be user state and the use of personalization to maintain user state.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry



    JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES