110 likes | 194 Views
Maintaining Application State. MIS3502: Application Integration and Evaluation David Schuff David.Schuff@temple.edu. The multi-page application? . Actually, we’ve been creating multi-page applications all semester.
E N D
Maintaining Application State MIS3502: Application Integration and Evaluation David SchuffDavid.Schuff@temple.edu
The multi-page application? • Actually, we’ve been creating multi-page applications all semester …But the pages in our applications don’t communicate with each other, only with themselves (the postback), or an external data source (an Access database) Access database: glenside.mdb
So? • This has worked because we are completing the entire transaction within a single page • Modification of a database record BUT • If you need to gather data across multiple pages to complete a transaction, then this doesn’t work • So you need a way to carry information across multiple pages
What is “state” • Status of an application • i.e., what are the values of the application’s variables • The HTTP protocol is “stateless” • One page doesn’t know what another page is doing • So other things have to be done to get information from one page to another
Why is this tricky? Multiple amazon.com sessions… amazon.com application server Each session must be treated separately (i.e., different items in the shopping cart) This information has to be kept track of somewhere…
One option: Avoiding the issue (client-side) • Post data from a form to a page • This treats each page like a separate component • Data has to be “handed off” from one component to another • There are some odd ways this gets implemented • Hidden HTML fields, complex URLs ASP.NET applications are set up to post data to themselves. This happens when we enable “AutoPostBack” in a DropDownList, or when a Button is clicked.
How to maintain state: Server-side • The “session state” object • ISAPI (Internet Server API) – Microsoft standard for doing this • The application running at the server maintains the state for every connected session • Communicates its state with the client
Session state object • Goes away when the browser is closed • Data is lost • Is persistent across pages of the same browser session • Can hold any data type =
How to maintain state: Client-side (cookie) Me like retaining values across multiple browser sessions! • The browser keeps track of data for other pages to “pick up” later • Small text files saved to the local hard drive • Does not go away when browser is closed (persistent) • Can only hold string values
When to use each? • What situation would you want to use a session variable? • What situation would you want to use a cookie? • Is there one which you should avoid using?
Summary: Session Variables versus Cookies Session Variables Cookies Server’s memory (RAM) Server’s memory (RAM) State information about a session is maintained at the server State information about a session is maintained at the browser